GitHub SWE Interview Question 2024 April | Matrix | on-campus

Question · Posted Jun 2026

Question 1: Spiral Matrix Problem Statement Given an m x n matrix, return all elements of the matrix in spiral order. Constraints m == matrix.length n == matrix[i].length 1 <= m, n <= 10 -100 <= matrix[i][j] <= 100 Examples Example 1: Input: matrix = [[1,2,3],[4,5,6],[7,8,9]] Output: [1,2,3,6,9,8,7,4,5] Explanation 1: Traverse top row [1,2,3], then right column [6,9], then bottom row [8,7] (backward), then left column [4] (upward), then middle element [5]. Total spiral sequence is [1,2,3,6,9,8,7,4,5]. Example 2: Input: ...

The full answer & interview discussion are available to premium members.

Log in Create a free account