原题题目
代码实现(首刷自解)
class Solution {
public:bool checkOnesSegment(string s) {
int flag = 1;for(int i=1;i<s.size();++i){
if(s[i] == '1'){
if(flag == 1) continue;else return false;}else if(flag == 1) flag = 0;}return true;}
};
class Solution {
public:bool checkOnesSegment(string s) {
int flag = 1;for(int i=1;i<s.size();++i){
if(s[i] == '1'){
if(flag == 1) continue;else return false;}else if(flag == 1) flag = 0;}return true;}
};