In-place List Reversal
LC #206Easy
Reverse Linked List
In-place List Reversal
AmazonGoogleMetaMicrosoftAppleProblem
Reverse a singly linked list in-place.
linked-list
Constraints
- ›0 ≤ n ≤ 5000
- ›-5000 ≤ Node.val ≤ 5000
- ›Both iterative and recursive solutions accepted
Example
Input
head = [1, 2, 3, 4, 5]Output
[5, 4, 3, 2, 1]