less than 1 minute read

Given a singly linked list node, and integers i and j, reverse the linked list from i to jth nodes, 0 indexed and inclusive.

You should return the head of the reversed list.

This should be done in \(\mathcal{O}(1)\) space.

Constraints

  • n ≤ 100,000 where n is the number nodes in node

https://binarysearch.com/problems/Reverse-an-Inner-Linked-List

Examples

Example 1

Input

  • node =
  • i = 1
  • j = 2

Output

  • answer =

Solution

Leave a comment