You are given an array a of distinct positive integers and an array rotate. For each value in rotate, perform that many left circular rotations on the original array a, not on the result of any previous query.
Return an array where each element is the index of the maximum value after the corresponding rotation.
Examples
01 · Example 1
a = [1, 2, 3] rotate = [1, 2, 3, 4] return = [1,0,2,1]
After one left rotation, the array is [2,3,1], so the maximum value 3 is at index 1. The other rotation counts produce maximum indexes 0, 2, and 1.
Constraints
1 <= a.length, rotate.length <= 1000001 <= a[i] <= 10000000000 <= rotate[i] <= 1000000000- Values in
aare distinct.
More Snowflake problems
- Effective Role PrivilegesPHONE SCREEN · Seen May 2026
- Closest Bathroom / Desk on a GridPHONE SCREEN · Seen May 2026
- Minimum Clicks Between Wiki PagesOA · Seen May 2026
- Minimum Index Distance Between Person and CakeOA · Seen May 2026
- Simple Array Rotation GameSeen Apr 2026
- String Formation (Also for AI/ML Software Engineer Intern :)OA · Seen Mar 2026
- Grid Traversal (Infrastructure Automation Internship)Seen May 2025
- Horizontal Pod Autoscaler (Infrastructure Automation Internship)Seen May 2025
public int[] getMaxElementIndexes(int[] a, int[] rotate) {
// write your code here
}a[1, 2, 3]
rotate[1, 2, 3, 4]
expected[1,0,2,1]
sign in to submit