C++ using segment tree (Beats 99.40% of Users)
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: O(N * Log N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(N)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n#pragma GCC optimize("03")\nstatic int __star = []{\n    ios_base::sync_with_stdio(0);\n    cin.tie(NULL),cout.tie(NULL);\n    return 0;\n}();\nclass NumArray {\n    vector<int> seg;\n    int n;\npublic:\n    \n    void built(int i, int l,int h, vector<int>& v)\n    {\n       \n        if(l==h) {seg[i]=v[l]; return ;}\n        int m=(l+h)/2;\n        built(i*2+1,l,m,v);\n        built(i*2+2,m+1,h,v);\n        seg[i]=seg[i*2+1]+seg[i*2+2];\n    }\n    void make(int i,int l,int h,int ind,int val)\n    {\n        if(l==h)\n        {\n            seg[i]=val;\n            return;\n        }\n        int m=(l+h)/2;\n        if(ind<=m)\n        {\n            make(i*2+1,l,m,ind,val);\n        }\n        else make(i*2+2,m+1,h,ind,val);\n        seg[i]=seg[i*2+1]+seg[i*2+2];\n        return ;\n    }\n    int solve(int i,int l,int h,int lt,int rt)\n    {\n        if(lt>h||rt<l) return 0;\n        if(lt<=l&&rt>=h) return seg[i];\n        int m=(l+h)/2;\n        int a=0;\n        a=solve(i*2+1,l,m,lt,rt);\n        a+=solve(i*2+2,m+1,h,lt,rt);\n        return a;\n    }\n    NumArray(vector<int>& nums) {\n         n=nums.size();\n        seg.resize(4*nums.size(),0);\n        built(0,0,nums.size()-1,nums);\n    }\n    \n    void update(int index, int val) {\n        make(0,0,n-1,index,val);\n    }\n    \n    int sumRange(int left, int right) {\n        return solve(0,0,n-1,left,right);\n    }\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```
['Segment Tree', 'C++']