Swap the K-th Node from the End with the Head in a Singly Linked List

Asked at Amplitude · Coding Questions · Difficulty: Medium · Last asked Jul 15, 2026

Given the head of a singly linked list `head` and an integer `k` (1-indexed), swap the **k-th node from the end** with the **head node**, using **O(1) extra space**, and return the new head.

Loading the problem…