Reported September 2024
Rubrikgreedy

Mike and Gems

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

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

Rubrik's September OA included Mike and Gems, a deceptively simple-looking problem that trips up candidates who don't catch the optimization trick. You've got a scenario involving collection or distribution, and the naive approach will time out. The real ask is recognizing when greedy or a sorted pass solves it in linear or near-linear time instead of brute force. StealthCoder reads the exact constraints and spits the pattern instantly if you blank on approach during the live session.

Pattern and pitfall

Mike and Gems hinges on recognizing that a greedy or sorting-based strategy beats simulation. Most candidates code a step-by-step loop, which balloons in complexity. The key is understanding the problem's structure: what's the global property you're optimizing, and can you compute it in one pass or with sorted input. Common pitfall is not reading the constraint range carefully; if N is up to 10^5, your O(N^2) solution isn't passing. The trick is often noticing that order matters, or that you can pre-sort and make a single decision per element. StealthCoder acts as your safety net during the OA if the approach doesn't click in the first five minutes.

If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.

If this hits your live OA

You can drill Mike and Gems 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 by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it.

Get StealthCoder

Related leaked OAs

⏵ The honest play

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

Rubrik reuses patterns across OAs. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Mike and Gems FAQ

Is this a simulation problem or a math/greedy problem?+

It's a greedy or sorting problem masquerading as simulation. Candidates who code step-by-step iteration hit time limits. Look for the property you're maximizing or minimizing, then see if one pass over sorted data solves it. That's your signal.

What's the most common wrong approach?+

Simulating Mike's actions one move at a time, trying every possibility or greedy choice recursively. That's O(N^2) or worse. The right approach pre-computes or sorts once, then walks the array once. Ask yourself: can I decide all answers in a single pass.

How do I prepare for this in 24 hours if I've never seen it?+

Study problems labeled greedy or sorting on LeetCode that involve collection and optimization (e.g., Assign Cookies, Jump Game). The pattern is always the same: sort or count, then decide. Rubrik isn't testing exotic algorithms, they're testing if you spot the standard trick.

Will Rubrik ask follow-up questions or optimize further?+

Possibly. If you submit a working solution, they may ask for better space complexity or a different trade-off. Have a second approach ready (e.g., a hash-based approach if your first was sorting). Know your solution's trade-offs cold.

What if I blank on the pattern during the OA?+

Don't panic. Write a brute-force or simulation that's correct but slow. It buys time. Then optimize once you see it passes small cases. That's where StealthCoder shines: it spots the pattern instantly and gives you the fix without you having to rederive it live.

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

OA at Rubrik?
Invisible during screen share
Get it