Dashboard
#19. Reverse Linked ListEasyLinked List

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

Example 1:

Input: head = [0,1,2,3]

Output: [3,2,1,0]

Example 2:

Input: head = []

Output: []

Constraints:

  • 0 <= The length of the list <= 1000.
  • -1000 <= Node.val <= 1000
Examples
Example 1:
Input: head = [0,1,2,3]
Output: [3,2,1,0]
Example 2:
Input: head = []
Output: []
Constraints
  • `0 <= The length of the list <= 1000`.
  • `-1000 <= Node.val <= 1000`
Company Frequency
Google18Oracle13Amazon8Qualcomm7Visa5Yandex5TCS4Apple4
Prerequisites
Target: O(N) time • O(1) spaceLinked List / Recursion
Socratic AI Tutor
Gemini 3.8 Flash
Loading editor...

Click "Run" or press Ctrl+Enter to execute test cases.