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. Android adb logcat输出日志显示不全解决方案

    在终端中使用adb logcat打印服务器json数据,如果返回数据过大超过4000字节(4K)即会截断不显示 原因:logcat在对于message的内存分配大概是4k左右.所以超过的内容都直接被丢 ...

  2. 【Mysql】mysql使用触发器创建hash索引

    概述 若设计的数据表中,包含较长的字段,比如URL(通常都会比较长),查询时需要根据该字段进行过滤: select * from table_xxx where url = 'xxxxxxx'; 为了 ...

  3. PAT 乙级 1046 划拳(15) C++版

    1046. 划拳(15) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 划拳是古老中国酒文化的一个有趣的组成部分 ...

  4. Hive之示例一:基本操作与案例

    1. 创建数据库,切换数据库 create database testdb; use testdb; 2. 创建管理表 create table emp( empno int, empname str ...

  5. Java-学习-喜欢-品牌:互联网公司成为动物园,拟人化品牌形象真的那么有意思?

    ylbtech-Java-学习-喜欢-品牌:互联网公司成为动物园,拟人化品牌形象真的那么有意思?  1.返回顶部 1. 当我们在思考如何在这个碎片化.多元化的时代找到真实的.不被标签的自我时,互联网中 ...

  6. [UE4]游戏中服务器切换地图,控制台命令Execute console Command

    Execute console Command ServerTravel {地图名称}?listen 在服务器执行了这个命令,所有连接到该服务器的客户端都会跟着服务器同时切换到指定的地图. 1.创建一 ...

  7. win7运行bat文件 一闪而过 解决 必须要将生成器放在C盘等没有中文的目录里

    1.在*.bat所在的文件夹按住shift 键然后鼠标右键,选择“在此处打开命令窗口”, 2.输入bat文件名称然后回车 这样就不会自动消失(只在win7 x64 上尝试过)

  8. android adb push 命令

    1.获得root权限:adb root 2.设置/system为可读写:adb remount 3.将PC机上文件复制到手机:adb push 文件名  /system/lib

  9. Oracle安装完成后如何创建表空间及用户

    1.select file_Name from dba_data_files;(查询表空间) 2.create tablespace QUAN datafile '/app/ADMINISTRATOR ...

  10. Centos7 配置ssh连接

    Centos7 配置ssh连接 1.检查是否安装openssh-server:#yum list installed | grep openssh-server 安装openssh-server:#y ...