Skip to content

Commit 6f21630

Browse files
authored
Create check-if-binary-string-has-at-most-one-segment-of-ones.cpp
1 parent 0058110 commit 6f21630

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Time: O(n)
2+
// Space: O(1)
3+
4+
class Solution {
5+
public:
6+
bool checkOnesSegment(string s) {
7+
return s.find("01") == string::npos;
8+
}
9+
};

0 commit comments

Comments
 (0)