Asked inAxtria,Analyst

Rotate Array Problem Statement

The task is to rotate a given array with N elements to the left by K steps, where K is a non-negative integer.

Input:

The first line contains an integer N representing the size of the array.

The second line contains N space-separated integers representing the elements of the array.

The last line contains an integer K representing the number of times the array has to be rotated in the left direction.

Output:

The output consists of N space-separated integers representing the rotated array elements.

Example:

Input:
N = 5
array = [1, 2, 3, 4, 5]
K = 2
Output:
[3, 4, 5, 1, 2]

Constraints:

  • 1 <= N <= 103
  • 1 <= arr[i] <= 109
  • 1 <= K < N
AnswerBot
4mo

Rotate a given array to the left by K steps.

  • Create a new array to store the rotated elements.

  • Use modular arithmetic to handle cases where K is greater than the array size.

  • Shift elements to the left by...read more

Help your peers!
Select
Add answer anonymously...

Axtria Analyst interview questions & answers

An Analyst was asked 2mo agoQ. What are SQL joins?
An Analyst was asked 5mo agoQ. Tell me more about the projects listed on your CV.
An Analyst was asked 8mo agoQ. What is the difference between SQL and NoSQL?

Popular interview questions of Analyst

An Analyst was asked 2mo agoQ1. What are SQL joins?
An Analyst was asked 5mo agoQ2. Tell me more about the projects listed on your CV.
An Analyst was asked 8mo agoQ3. What is the difference between SQL and NoSQL?
Axtria Analyst Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits