Question bank › Arrays
Dsa Arrays Medium

Rotate Array in Place

Given an array and an integer K, rotate the array to the right by K steps, where K is non-negative. Do this in place. Input Format: - The first line contains two integers, N (the number of elements in the array) and K. - The second line contains N space-separated integers representing the elements of the array. Output Format: - Print the rotated array as space-separated integers. Example: Input: 5 2 1 2 3 4 5 Output: 4 5 1 2 3

Key concepts

arraysin-placeslicing

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.