Maintain the sum of even numbers in an array while applying a sequence of value-update queries.
You are given an integer array and a list of update queries. Each query adds a value to one position in the array. After applying each query, return the sum of all even numbers currently in the array.
The key challenge is to avoid recomputing the even-sum from scratch after every update. Track how the affected element changes and update the running total efficiently.
nums.[val, index] meaning nums[index] += val.Return the even-sum after each query.
ans where ans[i] is the sum of all even numbers in nums after processing the i-th query.Example 1
Input
nums = [1,2,3,4] queries = [[1,0],[-3,1],[-4,0],[2,3]]
Output
[8,6,2,4]
Explanation
Start with even sum = 2 + 4 = 6.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.