Move the Nth Node of a Linked List to the Front

Problem

Given the head head of a nonempty singly linked list and an integer n, move the nth node to the front and return the new head. Preserve the relative order of all other nodes.

Modify th...

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Standard Input
Execution Result: