Skip to content

Commit 416a860

Browse files
committed
30
1 parent a56ea08 commit 416a860

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
class Solution {
2+
public:
3+
int leftMostColumnWithOne(BinaryMatrix &binaryMatrix) {
4+
vector<int>V=binaryMatrix.dimensions();
5+
int rows=V[0];
6+
int cols=V[1];
7+
if(rows==0 || cols==0){
8+
return -1;
9+
}
10+
int res=-1;
11+
int r=0;
12+
int c=cols-1;
13+
while(r<rows && c>=0){
14+
if(binaryMatrix.get(r,c)==1){
15+
res=c;
16+
c--;
17+
}
18+
else {
19+
r++;
20+
}
21+
}
22+
return res;
23+
}
24+
};

0 commit comments

Comments
 (0)