Spiral Matrix II
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
Given a positive integer n, build an n x n grid filled with the integers 1 through n^2, placed in clockwise spiral order.
The spiral starts at the top-left cell with 1, runs right along the top row, then down the right column, left along the bottom row, up the left column, and continues inward layer by layer until every cell is filled.
Return the grid as a list of n rows.
Examples
Constraints
- 1 <= n <= 20
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.