Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

binary gap

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);
Comment

PREVIOUS NEXT
Code Example
Javascript :: open pdf in browser javascript 
Javascript :: javascript change color of text input 
Javascript :: javascript enable clipboard 
Javascript :: javascript error logging 
Javascript :: how to hide title bar react-navigation 
Javascript :: react router dom v6 active link 
Javascript :: document.on chenage jquer 
Javascript :: jquery map 
Javascript :: how to show 1 to 10 odd numbers in javascript 
Javascript :: syntax function 
Javascript :: useparams example 
Javascript :: @ media min and max width material ui 
Javascript :: javascript arrow functions default parameter 
Javascript :: typescript class constructor overload 
Javascript :: write json file c# 
Javascript :: prisma seed 
Javascript :: sequelize order with include 
Javascript :: map index 
Javascript :: how to comment in a json file 
Javascript :: wordpress not loading jquery 
Javascript :: display amount with currency for jquery 
Javascript :: npm react copy to clipboard 
Javascript :: js get first element of array 
Javascript :: json stringify close circle 
Javascript :: run on load js 
Javascript :: discord client.send_message js 
Javascript :: if cart empty shopify 
Javascript :: array map destructuring 
Javascript :: ajax current url 
Javascript :: continuous scrolling js 
ADD CONTENT
Topic
Content
Source link
Name
2+7 =