1018-Binary-Prefix-Divisible-By-5

Sat 17 May 2025

https://leetcode.com/problems/binary-prefix-divisible-by-5

import pyutil as pyu
pyu.get_local_pyinfo()
print(pyu.ps2("python-dotenv"))
from typing import List
class Solution:
  def prefixesDivBy5(self, A: List[int]) -> List[bool]:
    ans = []
    num = 0

    for a in A:
      num = (num * 2 + a) % 5
      ans.append(num % 5 == 0)

    return ans
new Solution().prefixesDivBy5()

Score: 5

Category: leetcode