Skip to content

Latest commit

 

History

History
18 lines (16 loc) · 412 Bytes

1018.md

File metadata and controls

18 lines (16 loc) · 412 Bytes

1018. Binary Prefix Divisible By 5

Solution 1 (time O(n), space O(1))

class Solution(object):
    def prefixesDivBy5(self, nums):
        """
        :type nums: List[int]
        :rtype: List[bool]
        """
        ans = []
        cur_num = 0
        for num in nums:
            cur_num = cur_num * 2 + num
            ans.append(cur_num % 5 == 0)
        return ans