其他分享
首页 > 其他分享> > leetcode1029

leetcode1029

作者:互联网

根据题目的hint,使用单层循环计算:

 1 class Solution(object):
 2     def prefixesDivBy5(self, A: 'List[int]') -> 'List[bool]':
 3         n = len(A)
 4         result = list()
 5         preNum = 0
 6         for i in range(n):
 7             binNum = A[i]
 8             X = preNum * 2 + binNum
 9             if X % 5 == 0:
10                 result.append(True)
11             else:
12                 result.append(False)
13             preNum = X
14         return result

 

标签:leetcode1029,preNum,int,binNum,List,result,append
来源: https://www.cnblogs.com/asenyang/p/10631324.html