java || prefix sum solution
\nclass NumArray {\n    \n    int[] arr;\n    int sum = 0;\n    public NumArray(int[] nums) {\n        this.arr = nums;\n        for(int i=0; i<arr.length; i++)
```\nclass NumArray {\n    \n    int[] arr;\n    int sum = 0;\n    public NumArray(int[] nums) {\n        this.arr = nums;\n        for(int i=0; i<arr.length; i++) {\n            sum += arr[i];\n        }  \n    }\n    \n    public void update(int index, int val) {\n        sum = sum - arr[index] + val;\n        arr[index] = val;\n    }\n    \n    public int sumRange(int left, int right) {\n        int temp = sum;\n        for(int i=0;i<left;i++){\n            temp -= arr[i];\n        }\n        for(int i=arr.length-1;i>right;i--){\n            temp -= arr[i];\n        }\n        return temp;\n        \n    }\n}\n```
['Prefix Sum', 'Java']