Find row number of a binary matrix having maximum number of 1 s | C # program to find row with maximum 1 in row sorted binary matrix ; function for finding row with maximum 1 ; find left most position of 1 in a row find 1 st zero in a row ; Driver code
using System ; class GFG { static int N = 4 ; static void findMax ( int [ , ] arr ) { int row = 0 , i , j ; for ( i = 0 , j = N - 1 ; i < N ; i ++ ) { while ( arr [ i , j ] == 1 && j >= 0 ) { row = i ; j -- ; } } Console . Write ( " Row ▁ number ▁ = ▁ " + ( row + 1 ) ) ; Console . Write ( " , ▁ MaxCount ▁ = ▁ " + ( N - 1 - j ) ) ; } public static void Main ( ) { int [ , ] arr = { { 0 , 0 , 0 , 1 } , { 0 , 0 , 0 , 1 } , { 0 , 0 , 0 , 0 } , { 0 , 1 , 1 , 1 } } ; findMax ( arr ) ; } }