Range Sum Query - Immutable ❄️
Given an integer array nums
, handle multiple queries of the following type:
- Calculate the sum of the elements of
nums
between indicesleft
andright
inclusive whereleft <= right
.
Examples for array [-2, 0, 3, -5, 2, -1]
:
Query(0, 2) => 1
Query(2, 5) => -1
Query(0, 5) => -3
Problem at Leetcode
Start Chat