Question bank › Linked List
Dsa Linked List Easy

Rotate a Linked List

You are given a linked list and an integer k. Write a program that rotates the list to the right by k places. Input format: - The first line contains an integer n, the number of elements in the linked list. - The next n lines contain integers for the linked list. - The last line contains the integer k, the number of places to rotate. Output format: - Print the rotated linked list, each value on a new line. Example: Input: 5 1 2 3 4 5 2 Output: 4 5 1 2 3

Key concepts

linked_listrotating

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.