Showing:
Handle Score
@Ibrahim Nash 6424
@mb1973 5704
@Quandray 5245
@akhayrutdinov 5111
@saiujwal13083 5046
@sanjay05 3762
@kirtidee18 3673
@mantu_singh 3532
@marius_valentin_dragoi 3523
@sushant_a 3459
Print Diagonally
Easy Accuracy: 65.54% Submissions: 531 Points: 2

Give a N * N square matrix, return all the elements of its anti-diagonals from top to bottom.

Example 1:

Input:
N = 2
A = [[1, 2],
[3, 4]]
Output:
1 2 3 4
Explanation: Topmost anti-diagonal is [[1, ],
[ , ]]
Next anti-diagonal is [[ , 2],
â€‹                       [3,  ]]
and the last anti-diagonal is [[ ,  ],
â€‹                               [ , 4]]
Hence, elements will be returned in the
order {1, 2, 3, 4}.

Example 2:

Input:
N = 3
A = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
Output:
1 2 4 3 5 7 6 8 9

You don't need to read input or print anything. Your task is to complete the function downwardDigonal() which takes an integer N and a 2D matrix A[ ][ ] as input parameters and returns the list of all elements of its anti-diagonals from top to bottom.

Expected Time Complexity: O(N*N)
Expected Auxillary Space: O(N*N)

Constraints:
1 ≤ N, M ≤ 103
0 ≤ A[i][j] ≤ 106