Amazon Interview Question: print the matrix in spiral fo... | Glassdoor

Interview Question

Software Development Engineer Intern Interview(Student Candidate) Seattle, WA

print the matrix in spiral format (inside out). Not that

  difficult, but challenging if you have not heard of the question before (as was the case with me)

Interview Answer

1 Answer


public static void printMatrix(int[][] matrix, int rows, int col)
        int rowStart=0;
        int rowEnd=rows-1;
        int colStart=0;
        int colEnd=col-1;


            for(int i=rowEnd;i>rowStart;i--)


Piyush on Feb 7, 2016

Add Answers or Comments

To comment on this, Sign In or Sign Up.