Reported March 2026
Snowflakemath

Max Element Indexes After Rotations

Reported by candidates from Snowflake's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Snowflake OA. Under 2s to a working solution.
Founder's read

The Snowflake OA reported in March 2026 hides its trap in the rotation counts, not the array. Rotate values go up to 10^5 while the array can be tiny, so a naive solution that physically rotates the array for every query dies on time or gets the wrap wrong. It's a math and array problem dressed up as simulation. Find the max once, then answer each query with arithmetic. If you blank on the modulo direction during the live assessment, StealthCoder is the invisible safety net that can hand you the formula while you keep typing.

The problem

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 0-based index of the maximum value in a after the corresponding number of left circular rotations.

Function
getMaxElementIndexes(a: int[], rotate: int[]) → int[]

Examples
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 <= 105
1 <= rotate.length <= 105
0 <= rotate[i] <= 105
All values in a are distinct positive integers.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick: find the index p of the maximum in the original array once. After k left rotations, an element at index p moves to (p - k) mod n. That's the whole answer for each query, so total work is O(n + m). The pitfall is the edge case. In most languages, (p - k) % n goes negative when k > p, so you need ((p - k) % n + n) % n. Also reduce k mod n, since rotate[i] can be far larger than n, and rotate[i] = 0 must return p unchanged. Don't simulate rotations, and don't chain them: each query starts from the original array. Check example 1: p = 2, n = 3, k = 1 gives 1, k = 2 gives 0, k = 3 gives 2, k = 4 gives 1. Matches. If the modulo sign trips you mid-assessment, StealthCoder is the hedge that gives you the correct expression fast.

The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.

If this hits your live OA

You can drill Max Element Indexes After Rotations cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Snowflake's OA.

Snowflake reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Max Element Indexes After Rotations FAQ

How hard is Max Element Indexes After Rotations really?+

Easy once you see it, but it's built to punish brute force. With both arrays up to 10^5, rotating per query is O(n*m) and times out. The real solution is a single pass to find the max index and one formula per query. Ten lines of code.

What's the trick to solve it?+

Locate the max's original index p once. After k left rotations it lands at (p - k) mod n. Since a left rotation shifts elements toward lower indexes, you subtract. Then normalize negatives so the result stays in the range 0 to n-1.

What edge cases should I test?+

Test rotate value 0, a rotate value equal to n, a rotate value much larger than n, and a single-element array where the answer is always 0. Also test k greater than p, because that's where negative modulo bites in languages like Java, C++, and JavaScript.

Do rotations accumulate across queries?+

No. The problem says each rotation count applies to the original array a, not the result of a previous query. Every query is independent. Chaining them is a common misread and gives wrong output on example 1 after the first element.

How do I prepare for this in 48 hours?+

Practice index math under circular shifts. Write the formula for left and right rotation from memory, and run it on small arrays by hand. Know your language's modulo behavior with negatives. That covers this problem and its variants for the Snowflake OA.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Snowflake.

OA at Snowflake?
Invisible during screen share
Get it