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.
Be the first one to answer
Add answer anonymously...
Interview Questions Asked to Software Developer Intern at Other Companies
Top Skill-Based Questions for Encore Capital Group Software Developer Intern
Algorithms Interview Questions and Answers
250 Questions
Data Structures Interview Questions and Answers
250 Questions
Web Development Interview Questions and Answers
250 Questions
Operating Systems Interview Questions and Answers
250 Questions
System Design Interview Questions and Answers
250 Questions
C++ Interview Questions and Answers
150 Questions
Stay ahead in your career. Get AmbitionBox app


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
AmbitionBox Awards
Get AmbitionBox app

