📜  二进制间隙 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:05.560000             🧑  作者: Mango

代码示例1
function binaryGap(N) {
    const bin = (N >>> 0).toString(2);
    const gap = bin.substring(0, bin.lastIndexOf('1'));
    const arr = substr.split('1');
    return arr.sort().reverse()[0].length;
}

binaryGap(1041);