Solution in C++
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass NumArray {\npublic:\n    vector<int> st;\n    vector<int> vals;\n    int n;\n    NumArray(vector<int>& nums): n(nums.size()), st(4*nums.size(),0) {\n        vals = nums;\n        build(0, 0, n-1);\n    }\n\n    void build(int node, int start, int end) {\n        if (start == end) {\n            st[node] = vals[start];\n            return;\n        }\n        int mid = (start+end)/2;\n        build(2*node+1, start, mid);\n        build(2*node+2, mid+1, end);\n        st[node] = st[2*node+1]+st[2*node+2];\n    }\n\n    void updateST(int node, int start, int end, int index, int val) {\n        if (start == end) {\n            st[node] = val;\n            return;\n        }\n        int mid = (start+end)/2;\n        if (index<=mid) updateST(2*node+1, start, mid, index, val);\n        else updateST(2*node+2, mid+1, end, index, val);\n        st[node] = st[2*node+1]+st[2*node+2];\n    }\n\n    void update(int index, int val) {\n        updateST(0, 0, n-1, index, val);\n        vals[index] = val;\n    }\n\n    int sumRangeHelper(int node, int start, int end, int left, int right) {\n        if (start>right || end<left) return 0;\n        if (start>=left && end<=right) return st[node];\n        int mid = (start+end)/2;\n        int leftSum = sumRangeHelper(2*node+1, start, mid, left, right);\n        int rightSum = sumRangeHelper(2*node+2, mid+1, end, left, right);\n        return leftSum+rightSum;\n    }\n\n    int sumRange(int left, int right) {\n        return sumRangeHelper(0, 0, n-1, left, right);\n    }\n};\n/**\n * Your NumArray object will be instantiated and called as such:\n * NumArray* obj = new NumArray(nums);\n * obj->update(index,val);\n * int param_2 = obj->sumRange(left,right);\n */\n```
['C++']