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
Be the first one to answer
Add answer anonymously...
Axtria Analyst Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

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

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter