Tweaked find loop start challenge test cases and algorith discussion.

This commit is contained in:
Donne Martin 2015-07-05 16:49:37 -04:00
parent 20d5a6d12b
commit 55c40e91a5
2 changed files with 6 additions and 8 deletions

View File

@ -53,9 +53,8 @@
"* Empty list -> None\n", "* Empty list -> None\n",
"* Not a circular linked list -> None\n", "* Not a circular linked list -> None\n",
" * One element\n", " * One element\n",
" * Two elements\n", " * Two or more elements\n",
" * Three or more elements\n", "* Circular linked list general case"
"* General case"
] ]
}, },
{ {

View File

@ -52,9 +52,8 @@
"* Empty list -> None\n", "* Empty list -> None\n",
"* Not a circular linked list -> None\n", "* Not a circular linked list -> None\n",
" * One element\n", " * One element\n",
" * Two elements\n", " * Two or more elements\n",
" * Three or more elements\n", "* Circular linked list general case"
"* General case"
] ]
}, },
{ {
@ -66,14 +65,14 @@
"* Use two pointers i, j, initialized to the head\n", "* Use two pointers i, j, initialized to the head\n",
"* Increment i and j until they meet\n", "* Increment i and j until they meet\n",
" * j is incremented twice as fast as i\n", " * j is incremented twice as fast as i\n",
" * If j's next is NULL, we do not have a circular list\n", " * If j's next is None, we do not have a circular list\n",
"* When i and j meet, move j to the head\n", "* When i and j meet, move j to the head\n",
"* Increment i and j one node at a time until they meet\n", "* Increment i and j one node at a time until they meet\n",
"* Where they meet is the start of the loop\n", "* Where they meet is the start of the loop\n",
"\n", "\n",
"Complexity:\n", "Complexity:\n",
"* Time: O(n)\n", "* Time: O(n)\n",
"* Space: In-place" "* Space: O(1)"
] ]
}, },
{ {