Skip to content

1784-check-if-binary-string-has-at-most-one-segment-of-ones

DevGod
DevGod
Elf Vtuber
/**
* @param {string} s
* @return {boolean}
*/
var checkOnesSegment = function(s) {
let Z = s.indexOf("0");
let O = s.lastIndexOf("1");
return (Z == -1) ? true : O<Z ? true : false
};