FastPrepRead a Matrix in Spiral Order
Problems/Read a Matrix in Spiral Order

Read a Matrix in Spiral Order

Adobe logoAdobe● MediumINTERNPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: You read the values of a rectangular grid in clockwise spiral order. Two Adobe intern reports name this classic task by its usual title. The first is by a product intern hired on campus (interview August 2023, selected). It is the first coding problem of a one-hour video interview that later moved to operating systems, databases and object-oriented design. The author first wrote a version with many nested loops, was asked for a cleaner one, and moved to four boundary pointers. The second is a report of an on-campus internship drive (November 2023). It lists this among four easy coding questions in its technical interview. The others were an array question, a tree level-order walk and a graph search. Neither gives limits or examples.

The rules are those of the named task: clockwise from the top-left cell. We chose these limits: up to 50 rows and 50 columns, with values from -1000 to 1000. We wrote new examples.

Our version is about 95% the same as the reported questions.

You are given an m x n integer matrix. Return all of its values in spiral order: start at the top-left cell, go right along the top row, down the right column, left along the bottom row and up the left column, then repeat the same clockwise walk on the part that is left inside, until every cell has been read exactly once.

Function

spiralRead(matrix: int[][]) → List<Integer>

Examples

Example 1

matrix = [[4,-1,7],[0,9,2]]return = [4,-1,7,2,9,0]
matrix
01204-171092

Go right along the top row (4, -1, 7), down the last column (2), then left along the bottom row (9, 0). Every value is used once: [4,-1,7,2,9,0].

Example 2

matrix = [[5],[8],[3]]return = [5,8,3]
matrix
0051823

One column: the walk simply goes down it: [5,8,3].

Example 3

matrix = [[3,8,1],[6,2,7],[9,4,5]]return = [3,8,1,7,5,4,9,6,2]
matrix
012038116272945

The outer ring gives 3, 8, 1, 7, 5, 4, 9, 6. The center 2 comes last: [3,8,1,7,5,4,9,6,2].

Constraints

  • 1 <= matrix.length, matrix[i].length <= 50, and all rows have the same length
  • -1000 <= matrix[i][j] <= 1000

More Adobe Phone Screen questions

  • Evaluate a Parenthesized Integer ExpressionPHONE SCREEN · Seen Oct 2026
  • All Elements of Two BSTs in OrderPHONE SCREEN · Seen Aug 2026
  • Rotate an Array In PlaceOA · PHONE SCREEN · Seen Aug 2026
  • Binary Tree Level-Order Traversal by LevelsPHONE SCREEN · ONSITE INTERVIEW · Seen Aug 2026
  • Count Occurrences in a Sorted ArrayPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2026
  • Count Pairs with Absolute Difference KPHONE SCREEN · Seen Jul 2026
  • Count Subsets with Sum KPHONE SCREEN · Seen Jul 2026
  • Numbers with Exactly Three DivisorsPHONE SCREEN · Seen Jul 2026
  • Sum of Even Nodes on a Path in a Numbered Binary TreePHONE SCREEN · Seen Jul 2026
  • Largest Value in Every Sliding WindowPHONE SCREEN · Seen Jul 2026

Similar questions at other companies

  • Apply a 2048 Board MoveGlean · PHONE SCREENGlean interview questions
  • Spiral Order with ObstaclesTemu · PHONE SCREENTemu interview questions
  • Incremental Hard Attention with a KV CacheOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions
  • Spiral Matrix TraversalByteDance · PHONE SCREENByteDance interview questions
  • S-Shaped Matrix TraversalFox Corporation · PHONE SCREEN
  • Longest Consecutive Same-Color LineGoogle · PHONE SCREENGoogle interview questions
  • Process Minesweeper Game OperationsAmperity · PHONE SCREENAmperity interview questions
  • Diagonal TraverseHive · PHONE SCREENHive interview questions
  • Build a Bird’s-Eye-View Height GridNVIDIA · PHONE SCREENNVIDIA interview questions
  • Multi-Channel Valid ConvolutionTesla · PHONE SCREENTesla interview questions

Interview reports that mention this question

  • Adobe Product Intern Interviews: 15 Experiences (Part 3 of 4)
  • Adobe SWE Intern Interviews: 27 Experiences (Part 2 of 4)
  • Adobe Intern Interview Questions: 54 Experiences (Part 1 of 4)

Adobe interview experiences

  • Adobe Web, QA, DevOps, ML Roles: 13 Experiences (Part 3 of 3)
  • Adobe SWE Interviews, Level Unknown: 25 Experiences (Part 2 of 3)
  • Adobe Interviews, Level Unknown: 38 Experiences (Part 1 of 3)
All Adobe interview questionsSee Adobe hiring insights
Saved
class Solution {
    public List<Integer> spiralRead(int[][] matrix) {
        // Write your code here.
    }
}
Checking account…