题解 | #求最大连续bit数#
求最大连续bit数
http://www.nowcoder.com/practice/4b1658fd8ffb4217bc3b7e85a38cfaf2
while(line = readline()) {
const radix2 = parseInt(line).toString(2);
let subArr = [];
for (let i = 0; i <= radix2.length; i++) {
for (let j = i + 1; j <= radix2.length; j++) {
let temp = radix2.slice(i, j);
if (judge(temp)) {
subArr.push(temp.length);
}
}
}
print(Math.max.apply(null, subArr))
}
function judge(target) {
let reg = new RegExp('[0]', 'g')
let temp = target.match(reg);
return temp ? false : true;
}