Daily challenge for 2026-11-10
679. Balance Range Margin Queries
Given a non-empty array of integers changes representing daily balance adjustments, and a 2D array queries where each query is a pair of indices [left, right] (with 0 ≤ left ≤ right < len(changes)).
For each query, calculate the total sum of balance changes inside the inclusive range [left, right] minus the total sum of balance changes outside this range.
Return a list of results corresponding to each query in order.
Constraints:
There are 1–2,000 signed integer changes, each with absolute value at most 1,000,000, and 0–2,000 queries. Each query is [left,right] with 0 <= left <= right < the number of changes. Both endpoints belong to the inside range; all other entries belong to the outside range. Preserve query order.
Example:
Input: changes = [2, -1, 4, 3], queries = [[1, 2], [0, 3]]
Output: [-2, 8]