27. Anti Diagonal Traversal of Matrix
Last updated
Last updated
The problem can be found at the following link: Question Link
To traverse the anti-diagonals of the matrix,
I used a helper function fill
that starts at a given position (i, j)
and moves diagonally down until it reaches the border of the matrix.
I called this fill
function for the top row
and rightmost column
to cover all the anti-diagonals.
Time Complexity: O(N*N)
, where N is the total number of rows and columns in the matrix. We visit each element exactly once.
Auxiliary Space Complexity: O(N*N)
, where N is the total number of rows and columns in the matrix. This is the space required to store the output vector.
For discussions, questions, or doubts related to this solution, please visit our discussion section. We welcome your input and aim to foster a collaborative learning environment.
If you find this solution helpful, consider supporting us by giving a ⭐ star
to the getlost01/gfg-potd repository.