import sys

class Solution:
def sumEvenAfterQueries(self, A: 'List[int]', queries: 'List[List[int]]') -> 'List[int]':
result = list()
len0 = len(A)
len1 = len(queries)
len2 = len(queries[0])
sums = sys.maxsize for i in range(len1):
#print(i)
val = queries[i][0]
index = queries[i][1]
if sums == sys.maxsize:
A[index] += val
sums = 0
for j in range(len0):
cur0 = A[j]
if cur0 % 2 == 0:
sums += cur0
else:
cur = A[index] + val
if cur % 2 == 0:
if A[index] % 2 == 0:
sums += val
else:
sums += cur
A[index] = cur
else:
if A[index] % 2 == 0:
sums -= A[index]
else:
sums += 0
A[index] = cur
result.append(sums) return result

leetcode985的更多相关文章

  1. [Swift]LeetCode985. 查询后的偶数和 | Sum of Even Numbers After Queries

    We have an array A of integers, and an array queries of queries. For the i-th query val = queries[i] ...

随机推荐

  1. iis重新注册.netframework4.0

    开始-运行-CMD  (管理员权限运行) %windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i 废话不多说直接上图:

  2. mongodb并列查询,模糊查询

    在mongodb的查询语句中可以这么写{“a”:$gt(1),"a":$lt(5)} 但这么查询出来的值会做单个条件匹配,最终结果为a大于1的集合+a小于5的集合 如果需要实现去交 ...

  3. js中两个==和三个===的区别

    首先,== equality 等同,=== identity 恒等. ==, 两边值类型不同的时候,要先进行类型转换,再比较. ==,不做类型转换,类型不同的一定不等. 下面分别说明: 先说 ===, ...

  4. 自动化 数据分离 --A文件里面的类 中的函数 调用 B文件里面类 的函数 的方法

    记录: bb 要实例化 self.dr=dr,那么 iber_test类的 self.dr 才能带过去

  5. [ZZ]知名互联网公司Python的16道经典面试题及答案

    知名互联网公司Python的16道经典面试题及答案 https://mp.weixin.qq.com/s/To0kYQk6ivYL1Lr8aGlEUw 知名互联网公司Python的16道经典面试题及答 ...

  6. 搭建DUBBO项目解决DUBBO.XML标签报错的问题(转载)

    https://www.cnblogs.com/ajax-li/p/7856393.html 报错内容: Multiple annotations found at this line: - cvc- ...

  7. keras LSTM学习实例

    1. 购物时间预测 http://www.cnblogs.com/arkenstone/p/5794063.html https://github.com/CasiaFan/time_seires_p ...

  8. linux系统安装SNMP(可用)

    一般我们监控Linux都是通过SSH或Telnet方式,有时候我们不方便通过这两种方式,比如遇到监控端口因为安全原因被封禁.以及SSH需要密钥登录,这都会让监控工具很难直接远程连接.而通过SNMP的方 ...

  9. Anaconda的基本使用

  10. Version 版本定义规则

    Version 定义规则:2.3.1012 主版本号: 表示项目的重大架构变更此版本号: 表示较大范围的功能添加和变化增量版本号: 一般表示重大bug修复2.3.1012snapshot   快照al ...