FastPrepMove the Nth Linked-List Node to the Front
Problems/Move the Nth Linked-List Node to the Front

Move the Nth Linked-List Node to the Front

LinkedIn logoLinkedIn● EasyFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a LinkedIn phone screen. The report asks to move the nth node of a linked list to the start. Here, the position counts from one and is always valid. The node itself stays the same and the other nodes keep their order. We added finite limits. These details are our choices. The main step closely matches the report. Our version is about 90% the same as the reported question.

Given the head of a nonempty singly linked list and a one-based position n, move the actual node at position n to the front and return the new head. The first node has position 1.

Change links rather than copying or swapping node values. Every other node must keep its relative order. When n = 1, return the original list unchanged. The supplied position is always valid.

Function

moveNthToFront(head: ListNode, n: int) → ListNode

Examples

Example 1

head = [1,2,3,4]n = 3return = [3,1,2,4]
head
1234
→
return
3124
Moved or new

Relink the selected node before the old head; every other node keeps its relative order.

Example 2

head = [8]n = 1return = [8]
head
8
→
return
8

Relink the selected node before the old head; every other node keeps its relative order.

Example 3

head = [5,5,7]n = 3return = [7,5,5]
head
557
→
return
755
Moved or new

Relink the selected node before the old head; every other node keeps its relative order.

Constraints

  • 1 <= number of nodes <= 100000.
  • 1 <= n <= number of nodes.
  • -10^9 <= node.val <= 10^9.
  • The list is acyclic.

More LinkedIn Phone Screen questions

  • Maximum Product of a Contiguous SubarrayPHONE SCREEN · Seen Nov 2026
  • Maximum Sum of a Contiguous SubarrayPHONE SCREEN · Seen Nov 2026
  • Merge Two Sorted ListsPHONE SCREEN · Seen Nov 2026
  • Sqrt(x)PHONE SCREEN · Seen Nov 2026
  • Total Years of Work ExperiencePHONE SCREEN · Seen Nov 2026
  • Sum an Arbitrary-Dimensional ArrayPHONE SCREEN · Seen Oct 2026
  • Known Words Matching Phone DigitsPHONE SCREEN · Seen Oct 2026
  • Inverse-Depth Nested List SumPHONE SCREEN · Seen Oct 2026
  • Valid Number with ExponentsPHONE SCREEN · Seen Oct 2026
  • Sort a Quadratic-Transformed ArrayPHONE SCREEN · Seen Oct 2026

Similar questions at other companies

  • Reverse Linked ListByteDance · PHONE SCREEN · ONSITE INTERVIEWByteDance interview questions
  • Middle of a Linked ListCisco · PHONE SCREENCisco interview questions
  • Reverse a Linked ListApple · PHONE SCREENApple interview questions
  • Merge Two Sorted ListsIBM · PHONE SCREENIBM interview questions
  • Reverse a Singly Linked ListChubb · PHONE SCREENChubb interview questions
  • Remove All Repeated Values from a Linked ListArista Networks · PHONE SCREENArista Networks interview questions
  • Detect a Cycle in a Linked ListSalesforce · PHONE SCREENSalesforce interview questions
  • Find the Intersection Node of Two Linked ListsVisa · PHONE SCREENVisa interview questions
  • Reverse a Linked ListMygate · PHONE SCREENMygate interview questions
  • Remove Even-Positioned Linked-List NodesOracle · PHONE SCREENOracle interview questions

LinkedIn interview experiences

  • LinkedIn Senior MLE Interview Questions: 1 Experience
  • LinkedIn Staff AI Engineer Phone Screens: 1 Experience
  • LinkedIn Experienced MLE Onsite: 1 Experience
  • LinkedIn Coding with AI Interview: 4 Experiences
  • LinkedIn Experienced Infrastructure SWE Onsite: 1 Experience
All LinkedIn interview questionsSee LinkedIn hiring insights
Saved
/**
 * Definition for singly-linked list.
 * public class ListNode {
 *     int val;
 *     ListNode next;
 *     ListNode() {}
 *     ListNode(int val) { this.val = val; }
 *     ListNode(int val, ListNode next) { this.val = val; this.next = next; }
 * }
 */
class Solution {
    public ListNode moveNthToFront(ListNode head, int n) {
        // Write your code here.
    }
}
Checking account…