mirror of
https://github.com/donnemartin/interactive-coding-challenges.git
synced 2024-03-22 13:11:13 +08:00
Tweaked kth to last element challenge algorithm description.
This commit is contained in:
parent
55c40e91a5
commit
63bf44efac
|
@ -66,13 +66,13 @@
|
||||||
"## Algorithm\n",
|
"## Algorithm\n",
|
||||||
"\n",
|
"\n",
|
||||||
"* Setup two pointers, current and previous\n",
|
"* Setup two pointers, current and previous\n",
|
||||||
"* Give current a headstart, incrementing it once for k = 1, twice for k = 2, etc\n",
|
"* Give current a headstart, incrementing it once if k = 1, twice if k = 2, ...\n",
|
||||||
"* Increment both pointers until current reaches the end\n",
|
"* Increment both pointers until current reaches the end\n",
|
||||||
"* Return the value of previous\n",
|
"* Return the value of previous\n",
|
||||||
"\n",
|
"\n",
|
||||||
"Complexity:\n",
|
"Complexity:\n",
|
||||||
"* Time: O(n)\n",
|
"* Time: O(n)\n",
|
||||||
"* Space: In-place"
|
"* Space: O(1)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user