Skip to content

Commit ec794e3

Browse files
authored
Create binary-prefix-divisible-by-5.py
1 parent 929d105 commit ec794e3

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Time: O(n)
2+
# Space: O(1)
3+
4+
class Solution(object):
5+
def prefixesDivBy5(self, A):
6+
"""
7+
:type A: List[int]
8+
:rtype: List[bool]
9+
"""
10+
for i in xrange(1, len(A)):
11+
A[i] += A[i-1] * 2 % 5
12+
return [x % 5 == 0 for x in A]

0 commit comments

Comments
 (0)