Java: Create an array of its anti-diagonals from a given square matrix
Write a Java program to create an array of its anti-diagonals from a given square matrix.
Example:
Input :
1 2
3 4
Output:
[
[1],
[2, 3],
[4]
]
Input:
[10, 20, 30]
[50, 60, 70]
[90, 100, 110]
Output:
[10]
[20, 50]
[30, 60, 90]
[70, 100]
[110]
Sample Solution:
Java Code:
Sample Output:
[10, 20, 30] [50, 60, 70] [90, 100, 110] [10] [20, 50] [30, 60, 90] [70, 100] [110]
Flowchart:
For more Practice: Solve these Related Problems:
- Write a Java program to compute the diagonal sum of a square matrix.
- Write a Java program to rotate a given matrix by 90 degrees.
- Write a Java program to find the determinant of a square matrix.
- Write a Java program to check if a given matrix is symmetric.
Java Code Editor:
Previous: Write a Java program to find all the unique triplets such that sum of all the three elements [x, y, z (x ≤ y ≤ z)] equal to a specified number.
Next: Write a Java program to get the majority element from a given array of integers containing duplicates.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.