| 1 | //User function Template for Java |
| 2 | class Solution { |
| 3 | int rowWithMax1s(int arr[][], int n, int m) { |
| 4 | // code here |
| 5 | int col=m-1; |
| 6 | int row=-1; |
| 7 | // Traversing row by row |
| 8 | for(int i=0;i<n;i++) |
| 9 | { |
| 10 | // last column to first |
| 11 | for(int j=col;j>=0;j--) |
| 12 | { |
| 13 | if(arr[i][j]==1) |
| 14 | { |
| 15 | row=i; |
| 16 | // We will not see same column again |
| 17 | col--; |
| 18 | } |
| 19 | // if you see zero 0 then skip that row |
| 20 | else{ |
| 21 | break; |
| 22 | } |
| 23 | } |
| 24 | } |
| 25 | return row; |
| 26 | } |
| 27 | } |
nothing calls this directly
no outgoing calls
no test coverage detected