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
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Find maximum element of each column in a matrix
- Program to find the maximum element in a Matrix
- Maximum neighbor element in a matrix within distance K
- Replace every matrix element with maximum of GCD of row or column
- Maximum weight path ending at any element of last row in a matrix
- Find the element in the matrix generated by given rules
- Find sum of all Boundary and Diagonal element of a Matrix
- Find a sub matrix with maximum XOR
- Find row with maximum sum in a Matrix
- Find the original matrix when largest element in a row and a column are given
- Find column with maximum sum in a Matrix
- Find smallest and largest element from square matrix diagonals
- Find a common element in all rows of a given row-wise sorted matrix
- Find pair with maximum difference in any column of a Matrix
- Find Maximum side length of square in a Matrix
- Find maximum path length in a binary matrix
- Find alphabet in a Matrix which has maximum number of stars around it
- Find row with maximum and minimum number of zeroes in given Matrix
- Find pair of rows in a binary matrix that has maximum bit difference
- Find maximum path sum in a 2D matrix when exactly two left moves are allowed
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.