Skip to content

Commit 71dfab2

Browse files
authored
Create 1029-binary-prefix-divisible-by-5.js
1 parent fc99871 commit 71dfab2

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

1029-binary-prefix-divisible-by-5.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* @param {number[]} A
3+
* @return {boolean[]}
4+
*/
5+
const prefixesDivBy5 = function(A) {
6+
const res = []
7+
let pre = 0
8+
const len = A.length
9+
for(let i = 0; i < len; i++) {
10+
pre = (pre % 100) * 2 + A[i]
11+
res.push(pre % 5 === 0 ? true : false)
12+
}
13+
return res
14+
};

0 commit comments

Comments
 (0)