简单题,按照它给的说法计算就行.
class Solution: def sumEvenAfterQueries(self, A: List[int], queries: List[List[int]]) -> List[int]: s = sum(x for x in A if x % 2 == 0) ans = [] for v, i in queries: new = A[i] + v s += new if new % 2 == 0 else 0 s -= A[i] if A[i] % 2 == 0 else 0 ans.append(s) A[i] = new return ans
原文地址:https://www.cnblogs.com/zywscq/p/10699778.html
时间: 2024-11-13 07:55:53