Coding Trainer

Reverse Linked List II

MediumLinked List ReversalLC #92

Problem

Given the head of a linked list and two integers left and right, reverse the nodes from position left to right in one pass.

Example: head=[1,2,3,4,5], left=2, right=4 → [1,4,3,2,5]