# Time: O(n) # Space: O(1) class Solution(object): def prefixesDivBy5(self, A): """ :type A: List[int] :rtype: List[bool] """ for i in xrange(1, len(A)): A[i] += A[i-1] * 2 % 5 return [x % 5 == 0 for x in A]