Skip to main content
LeetCode 985, Medium. Topics: Array, Simulation. View on LeetCode. Generate this problem as a practice environment: tested reference solution, 18 parametrized pytest cases, and a playground notebook:

Problem

You are given an integer array nums and an array queries where queries[i] = [val_i, index_i]. For each query i, first, apply nums[index_i] = nums[index_i] + val_i, then print the sum of the even values of nums. Return an integer array answer where answer[i] is the answer to the i-th query.

Examples

Constraints

  • 1 <= nums.length <= 10^4
  • -10^4 <= nums[i] <= 10^4
  • 1 <= queries.length <= 10^4
  • -10^4 <= val_i <= 10^4
  • 0 <= index_i < nums.length

Solution

Reference implementation from solution.py on GitHub, full suite in test_solution.py:

Complexity

Tags

Last modified on September 7, 2026