Given a matrix, the task is to find the maximum element of each row.
Input : [1, 2, 3] [1, 4, 9] [76, 34, 21] Output : 3 9 76 Input : [1, 2, 3, 21] [12, 1, 65, 9] [1, 56, 34, 2] Output : 21 65 56
Approach : Approach is very simple. The idea is to run the loop for no_of_rows. Check each element inside the row and find for the maximum element. Finally, print the element.
Below is the implementation :
8 11 76 5
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Minimum element of each row and each column in a matrix
- Program to find the Sum of each Row and each Column of a Matrix
- Sum of matrix in which each element is absolute difference of its row and column numbers
- Sum of matrix element where each elements is integer division of row and column
- Maximum sum of elements from each row in the matrix
- Maximum sum of a Matrix where each value is from a unique row and column
- Maximum path sum that starting with any cell of 0-th row and ending with any cell of (N-1)-th row
- Maximum weight path ending at any element of last row in a matrix
- Replace every matrix element with maximum of GCD of row or column
- Find maximum element of each column in a matrix
- Find trace of matrix formed by adding Row-major and Column-major order of same matrix
- Minimum difference between adjacent elements of array which contain elements from each row of a matrix
- Minimum operations required to make each row and column of matrix equals
- Sum of GCDs of each row of the given matrix
- Print an N x M matrix such that each row and column has all the vowels in it
- Count of ways to generate a Matrix with product of each row and column as 1 or -1
- Find a common element in all rows of a given row-wise sorted matrix
- Find the original matrix when largest element in a row and a column are given
- Check if it is possible to get given sum by taking one element from each row
- Find row number of a binary matrix having maximum number of 1s
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.