01 · Question
Given an integer array nums, handle multiple queries of the form sumRange(left, right) returning the sum of elements between left and right inclusive.
02 · Analysis
Store pref[i] as the sum of the first i values, with pref[0]=0. For inclusive [left,right], subtract pref[left] from pref[right+1]; the shared earlier prefix cancels. Construction costs O(n) time/space; each valid query costs O(1). Negative values and left=0 require no special branch. The input remains unchanged after construction.