MCPcopy Create free account
hub / github.com/Tiwarishashwat/InterviewCodes / Solution

Class Solution

RowWithMax1s.java:2–27  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1//User function Template for Java
2class 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}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected