Reverse a Linked List
Given a singly linked list node
, return its reverse.
Bonus: Can you do this in \(\mathcal{O}(1)\) space?
Constraints
n ≤ 100,000
wheren
is the number of nodes innode
https://binarysearch.com/problems/Reverse-a-Linked-List
Examples
Example 1
Input
- node =
Output
- answer =
Example 2
Input
- node =
Output
- answer =
Leave a comment