Skip to content

Commit d916942

Browse files
authored
Create 1023-binary-string-with-substrings-representing-1-to-n.js
1 parent 4f89d6a commit d916942

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* @param {string} S
3+
* @param {number} N
4+
* @return {boolean}
5+
*/
6+
const queryString = function(S, N) {
7+
for(let i = 1; i <= N; i++) {
8+
let tmp = bin(i)
9+
if(S.indexOf(tmp) === -1) return false
10+
}
11+
return true
12+
};
13+
14+
function bin(num) {
15+
return (num >>> 0).toString(2)
16+
}

0 commit comments

Comments
 (0)