Sort the Matrix Diagonally
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
A matrix diagonal runs down and to the right: it starts at a cell in the top row or the leftmost column and continues through (i + 1, j + 1) until it leaves the matrix.
Given an m x n integer matrix mat, sort the values along every such diagonal in ascending order (smallest at the top-left end) and return the resulting matrix.
Examples
Constraints
- 1 <= m, n <= 100
- 1 <= mat[i][j] <= 100
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.