vault backup: 2022-09-20 13:19:16
This commit is contained in:
parent
beb42d5156
commit
2f2e8488d3
|
@ -23,6 +23,7 @@
|
||||||
##### Revisions:
|
##### Revisions:
|
||||||
|
|
||||||
2022-07-02
|
2022-07-02
|
||||||
|
2022-09-20
|
||||||
|
|
||||||
##### Related topics:
|
##### Related topics:
|
||||||
|
|
||||||
|
@ -70,8 +71,15 @@ Given the `head` of a singly linked list, reverse the list, and return _the reve
|
||||||
|
|
||||||
### Thoughts
|
### Thoughts
|
||||||
|
|
||||||
|
Many ways to implement this. from slow but easy ones, to
|
||||||
|
fast but hard ones:
|
||||||
|
|
||||||
|
#### Easy way:
|
||||||
|
|
||||||
I thought a slow O(n ^ 2) hybrid solution, while there are better algorithms, using in-place insert, or recursion.
|
I thought a slow O(n ^ 2) hybrid solution, while there are better algorithms, using in-place insert, or recursion.
|
||||||
|
|
||||||
|
#### Fast way:
|
||||||
|
|
||||||
The in place insert is easier to understand, and simple to implement, using a very clever trick.
|
The in place insert is easier to understand, and simple to implement, using a very clever trick.
|
||||||
|
|
||||||
> [!summary] My thoughts on the recursion algorithm
|
> [!summary] My thoughts on the recursion algorithm
|
||||||
|
|
Loading…
Reference in a new issue