Grokking 75: Top Coding Interview Questions
Ask Author
Back to course home

0% completed

Vote For New Content
Solution: Reverse Linked List II
On this page

Problem Statement

Given the head of a singly linked list and two positive integers left and right where left <= right, reverse all the nodes from the left to the right position, and return the updated list.

Examples

Example 1:

  • Input: [7, 8, 9, 10, 11], left = 2, right = 4
  • Expected Output: [7, 10, 9, 8, 11]
  • Justification: The nodes from position 2 to 4 (8, 9, 10) are reversed to become 10, 9, 8.

Example 2:

  • Input: [1, 2, 3, 4, 5, 6], left = 2, right = 5
  • Expected Output: [1, 5, 4, 3, 2, 6]

.....

.....

.....

Like the course? Get enrolled and start learning!

On this page