i used two way to solve the problem, one is head insertion, one is as in the problem 206 reverse linked list, just reverse the link between every node. but in my solution, it is also clumsy and complicated. compare with the official solution, i used while to loop, and use a lot of variable, pre-left, reversed-head, reversed-end, while in the official solution, they only used pre, pre.next is always the reversed-head, and they use for to loop, cur always pointer to reversed-end.it's so ingenious.
i also update my code of problem 206 reverse linked list accordingly, remove the temporary variable of reversed-head. it's more clean and neat.
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)