• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
December 28, 2023 |700 Views
PROBLEM OF THE DAY : 27/12/2023 | Anti Diagonal Traversal of Matrix
Description
Discussion

Welcome to the daily solving of our PROBLEM OF THE DAY with Karan Mashru. We will discuss the entire problem step-by-step and work towards developing an optimized solution. This will not only help you brush up on your concepts of Matrix but also build up problem-solving skills.

In this problem, we are given a N*N square matrix, return an array of its anti-diagonals in top-leftmost to bottom-rightmost order. In an element of a anti-diagonal (i, j), surrounding elements will be (i+1, j-1) and (i-1, j+1). Look at the examples for more clarity.

Example :

Input:
N = 2
matrix[][] = 1 2
                   3 4
Output:
1 2 3 4

Explanation:
List of anti-diagonals in order is {1}, {2, 3}, {4}

Give the problem a try before going through the video. All the best!!!
Problem Link: https://practice.geeksforgeeks.org/problems/print-diagonally1623/1