Given the head of a singly linked list, reverse it.
Example
Input: 1 -> 2 -> 3
Output: 3 -> 2 -> 1
Constraints: 1 ≤ n ≤ 10⁵
Given the head of a singly linked list, reverse it.
Example
Input: 1 -> 2 -> 3
Output: 3 -> 2 -> 1
Constraints: 1 ≤ n ≤ 10⁵
Asked in