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

0% completed

Reverse Linked List II (medium)
Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

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!

Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible