C++ Solution | fast and easy
\nclass NumArray {\npublic:\n    vector<int>v; //vector to store input vector.\n    int sum; //sum of all element of vector \n    NumArray(vector<int>& nums) {\
```\nclass NumArray {\npublic:\n    vector<int>v; //vector to store input vector.\n    int sum; //sum of all element of vector \n    NumArray(vector<int>& nums) {\n        v=nums;\n        sum=0;\n        for(int i=0;i<nums.size();i++){\n            sum+=nums[i];\n        }\n    }\n    \n    void update(int index, int val) {\n        sum-=v[index];     //subtract old element  from sum at index and then update by adding new element val.\n        v[index]=val;\n        sum+=val;\n        \n    }\n    \n    int sumRange(int left, int right) {\n        int res=sum; \n        for(int i=0;i<left;i++){    //subtract all element before left and after right\n            res-=v[i];\n        }\n        for(int i=right+1;i<v.size();i++){\n            res-=v[i];\n        }\n        return res;// return res ie. our answer.\n    }\n};\n```
['C']