Range Sum Query Immutable Leetcode Javascript Question