Anti Diagonals

Give a N*N square matrix, return an array of its anti-diagonals. Look at the example for more details.

Example:

		
Input: 	

1 2 3
4 5 6
7 8 9

Return the following :

[ 
  [1],
  [2, 4],
  [3, 5, 7],
  [6, 8],
  [9]
]


Input : 
1 2
3 4

Return the following  : 

[
  [1],
  [2, 3],
  [4]
]

Interview Code Editor
Hints
  • Hint 1
  • Solution Approach
  • Complete Solution
5836 successful submissions.
Asked In:
  • Microsoft
  • Adobe
Click here to jump start your coding interview preparation