Free beta: free to use with daily limits while we build. Join the waitlist for founding-member pricing at launch. Join the waitlist

Sign up free

Robinhood interview question

Rotate an n x n matrix clockwise in place with constant extra space

Company:
Robinhood
Type:
Coding
Difficulty:
Medium
Reported:
November 16, 2026

Problem

Input: a square 2D integer matrix. Output: the same matrix mutated in place so that it is rotated 90 degrees clockwise.

Requirements stated by the interviewer:

  • The mutation must happen on the input array; allocating a parallel output matrix is not accepted.
  • Elements must be moved using constant extra space.

Example 1

Input: matrix = [[1,2,3],[4,5,6],[7,8,9]]
Output: [[7,4,1],[8,5,2],[9,6,3]]

Row r of the result is column r of the input read from bottom to top.

Example 2

Input: matrix = [[1]]
Output: [[1]]

A single cell does not move.

Constraints

  • The matrix is square.
  • Other limits not stated; ask the interviewer.

Reported by candidates or drawn from publicly available sources, and rewritten in our own words. Pathwise Prep does not publish confidential assessment content. Report a concern