Range Sum Query - Immutable
Easy · Arrays & Strings · about 10 minutes
Asked at Meta, Amazon, Google, Microsoft, Bloomberg.
Answer many range-sum queries on a fixed array.
NumArray(nums)stores the array.sumRange(left, right)returns the sum ofnums[left..right](inclusive).