Simple Array Rotation Game
Updated
Problem statement
You are given an array of distinct positive integers and another array that specifies the number of left circular rotations to be performed.
Rotation Rule:
- A left circular rotation shifts all elements one position to the left.
- The element at index
0moves to the last position. - All other elements shift left by one index.
Task:
For each rotation value in the rotations array:
- Perform the rotation on the original array (not cumulative).
- Determine the index of the maximum element after the rotation.
Function
getMaxRotationIndexes(a: int[], rotations: int[]) → int[] Complete the function getMaxRotationIndexes.
getMaxRotationIndexes has the following parameters:
int a[]: Array of distinct integers.int rotations[]: Array representing the number of rotations.
Returns int[]: Array where each element represents the index of the maximum element after corresponding rotations.
Examples
Example 1
a = [1, 2, 3]rotations = [1, 2, 3]return = [1, 0, 2]For each rotation, the array [1, 2, 3] is rotated starting from the original (not cumulative):
- Rotation 1 →
[2, 3, 1], max = 3 at index 1 - Rotation 2 →
[3, 1, 2], max = 3 at index 0 - Rotation 3 →
[1, 2, 3], max = 3 at index 2
Constraints
- 1 ≤ n, m ≤ 500000
- 1 ≤ a[i] ≤
10^9 - 0 ≤ rotations[i] ≤
10^9
More Snowflake interview questions
- Connect Four from the Last MovePHONE SCREEN · Seen Nov 2026
- Minimum Edits to a Perfect Binary TreePHONE SCREEN · Seen Nov 2026
- Parallel Courses IIIONSITE INTERVIEW · Seen Nov 2026
- Safest Shortest Path Through a GridOA · Seen Nov 2026
- Configurable Per-Client Token BucketsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Find Valid SET Card TriplesOA · PHONE SCREEN · Seen Nov 2026
- LFU CacheOA · ONSITE INTERVIEW · Seen Nov 2026
- Minimum Index Distance Between Person and CakeOA · PHONE SCREEN · Seen Nov 2026
- Minimum N-ary Tree Depth DeletionsOA · PHONE SCREEN · Seen Nov 2026
- Sum of Binary Tree Boundary NodesOA · PHONE SCREEN · Seen Nov 2026
Similar questions at other companies
- Total Cost Against the Lowest Earlier PricePayPal · OAPayPal interview questions
- Count Valid Square PairsAuxoAI · OA
- Picked Player Who LostSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
- Server InvestmentRippling · OARippling interview questions
- Basic Item DiscountsPalantir · OAPalantir interview questions
- Next Pascal Row CoefficientIntuit · OAIntuit interview questions
- Unique Integers That Sum to ZeroNVIDIA · OANVIDIA interview questions
- Count Multiples of Three with Two SevensHudson River Trading · OAHudson River Trading interview questions
- Diagonal Bounce TraversalAutodesk · OAAutodesk interview questions
- Maximum Student-Teacher DistanceChubb · OAChubb interview questions