C++ Simple Segment-Tree Solution
```\nclass NumArray {\npublic:\n    int n;\n    vectorseg;\n    void build(int index,int low,int high,vectornums)\n    {\n        if(low==high)\n        {\n    
```\nclass NumArray {\npublic:\n    int n;\n    vector<int>seg;\n    void build(int index,int low,int high,vector<int>nums)\n    {\n        if(low==high)\n        {\n            seg[index]=nums[low];\n            return;\n        }\n        int mid=(low+high)/2;\n        build(2*index+1,low,mid,nums);\n        build(2*index+2,mid+1,high,nums);\n        seg[index]=seg[2*index+1]+seg[2*index+2];\n        \n    }\n    \n    int query(int index,int low,int high,int l,int r)\n    {\n\n        if(low>=l && high<=r)  \n        {\n            return seg[index];\n        }\n        if(high<l || low >r) return 0;   \n\n        int mid=(low+high)/2;\n        int left=query(2*index+1,low,mid,l,r);\n        int right=query(2*index+2,mid+1,high,l,r);\n        return left+right;\n    }\n\n    \n    \n     void updatehelper(int ind,int low,int high,int pos,int val)\n     {\n        if(low==high)\n        {\n            seg[ind]=val;\n        }\n        else\n        {\n            int mid=(low+high)/2;\n            if(pos<=mid)\n            {\n                updatehelper(2*ind+1,low,mid,pos,val);\n            }\n            else\n            {\n                updatehelper(2*ind+2,mid+1,high,pos,val);\n            }\n            seg[ind]=seg[2*ind+1]+seg[2*ind+2];\n         }\n     }\n    \n    NumArray(vector<int>& nums) {\n        n=nums.size();\n        if(n==0)\n            return ;\n        seg.resize(4*n);\n        \n        build(0,0,n-1,nums);\n        \n    }\n    \n    \n    void update(int i, int val) {\n        updatehelper(0,0,n-1,i,val);\n    }\n    \n    int sumRange(int i, int j) {\n        return query(0,0,n-1,i,j);\n        \n    }\n};\n\n/**\n * Your NumArray object will be instantiated and called as such:\n * NumArray* obj = new NumArray(nums);\n * obj->update(i,val);\n * int param_2 = obj->sumRange(i,j);\n */
['Tree', 'C', 'C++']