Created
July 2, 2022 19:57
-
-
Save allenhwkim/2aacd7bf80f47e7b58aa6f5b92a77270 to your computer and use it in GitHub Desktop.
Binary Gap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function solution(N) { | |
| const binString = N.toString(2); | |
| const matches = binString.replace(/[0]+$/, '').match(/0+/g); | |
| return (matches || []).reduce( (acc, cur) => Math.max(acc, cur.length), 0); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment