Rotating the Box
A medium-tier problem at 79% community acceptance, tagged with Array, Two Pointers, Matrix. Reported in interviews at Block and 5 others.
Rotating the Box is asked at Block, Visa, Uber, Capital One, Commvault, and Roblox. It's a medium-difficulty array problem with a 79% acceptance rate, which means most people who see it pass, but the trick isn't obvious on first read. You're given a box (matrix) with stones and obstacles. Gravity pulls stones down, but obstacles block them. You need to rotate the box 90 degrees clockwise and apply gravity again. The catch: if you simulate rotation naively, you'll waste time rebuilding the matrix. The real approach uses a different kind of two-pointer scan. If this problem hits your live OA and you blank on the pattern, StealthCoder solves it in seconds, invisible to the proctor.
Companies that ask "Rotating the Box"
Rotating the Box is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Made by an Amazon engineer who watched the leaked-problem repo become an industry secret. He decided you should have it too.
Get StealthCoderThe naive trap is to physically rotate the matrix, then simulate gravity. Instead, think backwards: rotate the problem conceptually. Process each column from right to left (as if the box has already turned 90 degrees). Within each rotated column, stones fall to the bottom, blocked by obstacles. Two pointers: one scans top-to-bottom to find stones and obstacles, another tracks where the next stone should land. This avoids the matrix rotation step and keeps memory usage low. Common miss: forgetting that obstacles themselves stay in place and act as barriers. Another miss: not handling the edge case where a stone lands directly above an obstacle. The two-pointer technique here isn't the classic 'converge from edges' pattern; it's more of a single-pass scan with a write-head. StealthCoder is your hedge if you freeze on whether to rotate first or rethink the geometry.
Pattern tags
You know the problem.
Make sure you actually pass it.
Rotating the Box recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Made by an Amazon engineer who watched the leaked-problem repo become an industry secret. He decided you should have it too. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Rotating the Box interview FAQ
Is this still asked at FAANG-adjacent companies?+
Yes. Block, Visa, and Uber all report it. The 79% acceptance rate means it's not a trap problem, but it does test whether you can reframe a spatial problem instead of brute-forcing it. If you can pass this, you signal strong problem-decomposition skills.
What's the actual trick?+
Don't rotate the matrix first. Process columns right-to-left as if rotation already happened. Use two pointers within each column: one scans for stones and obstacles, the other tracks the landing position. This eliminates the O(m*n) rotation step and makes the logic clearer.
How does this relate to the two-pointer topic?+
Two pointers here aren't the classic converge pattern. Instead, one pointer reads (identifies stones and obstacles), another writes (places stones in their final position). It's a single-pass, two-role technique. Understanding this variant opens doors to other grid-simulation problems.
What's the most common mistake candidates make?+
Simulating gravity twice: once before rotation, once after. Or, rotating the matrix explicitly with nested loops, then simulating. Both work but are slow and error-prone. The real catch is realizing you don't need to actually rotate the data structure.
How long should this take to code in an OA?+
If you see the pattern, 10 to 15 minutes. If you start by rotating the matrix, 25 to 30 minutes plus debugging. The acceptance rate suggests most people either know the trick or figure it out under time pressure. Your decision tree: physics first or geometry first.
Want the actual problem statement? View "Rotating the Box" on LeetCode →