题目:
今天这题目算是昨天303的威力加强版,思路是按昨天的来,先计算好每个数组各种排列的索引元素的和,然后再稍微一减。最后把和相加。
代码如下:
class NumMatrix:
def __init__(self, matrix: List[List[int]]):
self.num_sum = []
for i in matrix:
cache=[0]
for t in range(len(i)):
cache.append(cache[t]+i[t])
self.num_sum.append(cache)
def sumRegion(self, row1: int, col1: int, row2: int, col2: int) -> int:
re=0
if row2-row1 >0:
for i in range(row2-row1+1):
re += self.num_sum[row1+i][col2+1]-self.num_sum[row1+i][col1]
else:
re = self.num_sum[row1][col2+1]-self.num_sum[row1][col1]
return re
速度有点慢,我想想怎么改进
拍拍
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
拍拍
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
请教问题:我想投票nutbox作为见证人,为什么老是提示 Oops, something went wrong. Here is the error message:
"voter.proxy.size() == 0: A proxy is currently set, please clear the proxy before voting for a witness." ,
是因为uses maiyude as a voting proxy?
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit