Left Rotations of an Array

Given an array of size N and Q queries, each query requires left rotating the original array by a specified number of elements. Return the modified array for each query.

Input:

The first line contains an integer 'T', denoting the number of test cases. The first line of each test case contains two integers, 'N' and 'Q'. The second line contains 'N' space-separated integers representing the array elements. The third line contains 'Q' space-separated integers representing each query.

Output:

For every query of each test case, return 'N' space-separated integers representing the array after rotation for that query.

Example:

Let array = [1, 2, 3, 4, 5, 6] and queries = {2, 4, 1}. Output for each query is: [3, 4, 5, 6, 1, 2], [5, 6, 1, 2, 3, 4], [2, 3, 4, 5, 6, 1].

Constraints:

  • 1 <= T <= 10
  • 1 <= N <= 1000
  • 1 <= Q <= 100
  • 0 <= Queries[i] <= 105
  • -105 <= Array[i] <= 105

Note:

Each query should be processed on the original array.

AnswerBot
1y

The question seems to be gibberish and does not make sense.

  • I'm sorry, but I don't understand the question.

  • Could you please repeat or rephrase the question?

  • I am not able to provide an answer to this qu...read more

Help your peers!
Add answer anonymously...
Digital Web Analytics and Optimization Software Developer 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