mirror of
https://github.com/donnemartin/interactive-coding-challenges.git
synced 2024-03-22 13:11:13 +08:00
Tweaked find loop start challenge test cases and algorith discussion.
This commit is contained in:
parent
20d5a6d12b
commit
55c40e91a5
|
@ -53,9 +53,8 @@
|
|||
"* Empty list -> None\n",
|
||||
"* Not a circular linked list -> None\n",
|
||||
" * One element\n",
|
||||
" * Two elements\n",
|
||||
" * Three or more elements\n",
|
||||
"* General case"
|
||||
" * Two or more elements\n",
|
||||
"* Circular linked list general case"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
|
@ -52,9 +52,8 @@
|
|||
"* Empty list -> None\n",
|
||||
"* Not a circular linked list -> None\n",
|
||||
" * One element\n",
|
||||
" * Two elements\n",
|
||||
" * Three or more elements\n",
|
||||
"* General case"
|
||||
" * Two or more elements\n",
|
||||
"* Circular linked list general case"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -66,14 +65,14 @@
|
|||
"* Use two pointers i, j, initialized to the head\n",
|
||||
"* Increment i and j until they meet\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",
|
||||
"* Increment i and j one node at a time until they meet\n",
|
||||
"* Where they meet is the start of the loop\n",
|
||||
"\n",
|
||||
"Complexity:\n",
|
||||
"* Time: O(n)\n",
|
||||
"* Space: In-place"
|
||||
"* Space: O(1)"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user