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
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- Program to find the maximum element in a Matrix
- Find maximum element of each column in a matrix
- Replace every matrix element with maximum of GCD of row or column
- Maximum neighbor element in a matrix within distance K
- 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 a common element in all rows of a given row-wise sorted matrix
- Find smallest and largest element from square matrix diagonals
- Find Maximum side length of square in a Matrix
- Find maximum path length in a binary matrix
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.