Skip to content
AITroveRead. Build. Understand.

Reverse a Linked List

EasyPoints 2

Given the head of a singly linked list, reverse it.

Example

Code
Input: 1 -> 2 -> 3
Output: 3 -> 2 -> 1

Constraints: 1 ≤ n ≤ 10⁵

Asked in

Amazon
Microsoft
linked-list
Autosave off · demo editor
Storage details