EasyLinked ListsAI interview only
Reverse Linked List
Asked atamazongooglemicrosoftappleadobe
01 · Problem
Given the head of a singly linked list, reverse the list, and return the reversed list.
02 · Examples
Example 01
Input
head = [1,2,3,4,5]
Output
[5,4,3,2,1]
The linked list 1 -> 2 -> 3 -> 4 -> 5 becomes 5 -> 4 -> 3 -> 2 -> 1 after reversal.
Example 02
Input
head = [1,2]
Output
[2,1]
The linked list 1 -> 2 becomes 2 -> 1 after reversal.
03 · Constraints
- 01The number of nodes in the list is the range [0, 5000].
- 02-5000 <= Node.val <= 5000
04 · Optimal complexity
- Time
- O(n)
- Space
- O(1)
05 · Two ways to work on it
Practice it alone or rehearse it as an interview.
Practice Mode gives you an editor and test runs, nothing else. AI Interview Mode puts a voice interviewer on the other side, adds a clock, and ends with a scored summary of the round.