Sum of Even Numbers After Queries
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
You are given an integer array nums and a list of queries, where queries[i] = [val, index].
Process the queries in order. For each one, add val to nums[index] (the change persists for later queries), and then record the sum of all **even** values currently in nums (negative even numbers count; 0 is even).
Return the recorded sums as an array, one per query. Aim for O(n + q) total time.
Examples
Constraints
- `1 <= nums.length <= 10^4`
- `-10^4 <= nums[i] <= 10^4`
- `1 <= queries.length <= 10^4`
- `-10^4 <= val <= 10^4`
- `0 <= index < nums.length`
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.