Binary Prefix Divisible By 5: Combining a bit shift with modulo
This solution has a space complexity of O(n) because the length of the list returned is n. But if we use a generator instead, this becomes O(1). We iterate thro
This solution has a space complexity of `O(n`) because the length of the list returned is `n`. But if we use a generator instead, this becomes `O(1)`. We iterate through each bit in the list, shifting as we go, and adding true or false to the results, based on whether `n % 5 == 0`. So the time complexity is also `O(n)`.\n\n```\nclass Solution:\n  def prefixesDivBy5(self, nums: List[int]) -> List[bool]:\n    results = []\n    n = 0\n    for bit in nums:\n      n <<= 1\n      n += bit\n      results.append(n % 5 == 0)\n    return results\n```
[]