Reverse Linked List
Given the head of a singly linked list, reverse the list, and return the reversed list.

30:00

Reverse Linked List
easy
Topics
Companies

Given the head of a singly linked list, reverse the list, and return the reversed list.

Example 1:
Input: {"head":[1,2,3,4,5]}
Output: [5,4,3,2,1]
Constraints:
  • The number of nodes is in the range [0,5000][0, 5000].

  • 5000Node.val5000-5000 \leq \text{Node.val} \leq 5000

Input
arr ={"head":[1,2,3,4,5]}

Init: prev = null, curr = head

curr

1

2

3

4

5

NULL

prev → NULL

nxt → NULL

Variables
No variables to display
DepthFunction Call
Stack empty
0/26