Reported June 2026
Luma AImatrix

Rotate a Rectangular Image Clockwise

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

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

Luma AI reported this one in June 2026, and the constraint is the first thing to read: H and W top out at 200. That's 40,000 cells, so there's no brute force to dodge here. Any O(H*W) pass is fine. The real risk is the index math on a non-square grid, where the in-place rotation trick you memorized falls apart. You're returning a new W x H image, so you get to allocate. If the OA has you staring at the indices, StealthCoder is the safety net that runs invisibly and hands you the mapping if you blank.

The problem

Given an H × W grayscale integer image, return a new W × H image rotated 90 degrees clockwise.

Function
rotateClockwise(image: int[][]) → int[][]

Examples
Example 1
image = [[1,2,3],[4,5,6]]
return = [[4,1],[5,2],[6,3]]
The first output row is the original first column read bottom to top.

Constraints
1 <= H, W <= 200.
Every row has exactly W entries.

Reported by candidates. Source: FastPrep

Pattern and pitfall

This is a matrix problem with one idea: cell (r, c) in the input lands at (c, H-1-r) in the output. Allocate a W x H result, loop every input cell once, and write it there. That's O(H*W) time and space, which is exactly what 200 x 200 allows. The pitfall is the in-place square rotation you've seen on LeetCode. It doesn't work for rectangles, because the dimensions swap. Another trap is swapping H and W when you size the output, which gives index errors on Example 1's 2x3 input. Sanity check with the example: the first output row is the first column read bottom to top, so [4,1]. Test a 1xN and Nx1 image too. If the mapping slips away mid-assessment, StealthCoder is the hedge that reads the problem and gives you working code without the proctor seeing it.

Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.

If this hits your live OA

You can drill Rotate a Rectangular Image Clockwise 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. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.

Get StealthCoder

Related leaked OAs

⏵ The honest play

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

Luma AI reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Rotate a Rectangular Image Clockwise FAQ

How hard is Rotate a Rectangular Image Clockwise really?+

Easy if you've seen the matrix rotation idea, and still easy if you haven't. There's no clever algorithm. You allocate a W x H grid and copy each cell to its rotated position. Most failures come from swapped dimensions or off-by-one indices, not from the concept.

What's the trick to the index mapping?+

Input cell (r, c) goes to output (c, H-1-r). Output has W rows and H columns. Verify with Example 1: input value 4 sits at (1,0) and lands at (0,0). Value 1 at (0,0) lands at (0,1). That matches [4,1] as the first row.

Can I rotate in place like the square version?+

No. The function returns a new W x H image, and a rectangle changes shape when rotated, so in-place swapping doesn't apply. Just build a fresh array. With H and W at most 200, the extra memory is trivial and the code stays simple.

What edge cases should I test before submitting?+

Try a 1x1 image, a single row like 1xN, and a single column like Nx1. A single row becomes a single column and the reverse. Also confirm the 2x3 example gives [[4,1],[5,2],[6,3]]. These catch nearly every dimension mix-up.

How do I prepare for this in 48 hours?+

Write the rotation mapping by hand on a small 2x3 grid until you can derive it without looking. Then code it once, plus the transpose-then-reverse-each-row alternative. That's a short session. Spend the rest of your time on other matrix and array patterns that might show up.

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

OA at Luma AI?
Invisible during screen share
Get it