leetcode1018】的更多相关文章

Given an array A of 0s and 1s, consider N_i: the i-th subarray from A[0] to A[i] interpreted as a binary number (from most-significant-bit to least-significant-bit.) Return a list of booleans answer, where answer[i] is true if and only if N_i is divi…
根据题目的hint,使用单层循环计算: class Solution(object): def prefixesDivBy5(self, A: 'List[int]') -> 'List[bool]': n = len(A) result = list() preNum = 0 for i in range(n): binNum = A[i] X = preNum * 2 + binNum if X % 5 == 0: result.append(True) else: result.appen…