JAVA || Easy Solution || 100% faster Code
\tPLEASE UPVOTE IF YOU LIKE.\n\nclass NumArray {\n  static class BinaryIndexedTree {\n    int[] nums;\n    int[] BIT;\n    int n;\n\n    public BinaryIndexedTre
\tPLEASE UPVOTE IF YOU LIKE.\n```\nclass NumArray {\n  static class BinaryIndexedTree {\n    int[] nums;\n    int[] BIT;\n    int n;\n\n    public BinaryIndexedTree(int[] nums) {\n      this.nums = nums;\n      this.n = nums.length;\n      BIT = new int[n + 1];\n      for (int i = 0; i < n; i++) {\n        init(i, nums[i]);\n      }\n    }\n\n    void init(int i, int val) {\n      i++;\n      while (i <= n) {\n        BIT[i] += val;\n        i += (i & -i);\n      }\n    }\n\n    void update(int i, int val) {\n      int diff = val - nums[i];\n      nums[i] = val;\n      init(i, diff);\n    }\n\n    int getSum(int i) {\n      i++;\n      int ret = 0;\n      while (i > 0) {\n        ret += BIT[i];\n        i -= (i & -i);\n      }\n      return ret;\n    }\n  }\n\n  BinaryIndexedTree binaryIndexedTree;\n\n  public NumArray(int[] nums) {\n    binaryIndexedTree = new BinaryIndexedTree(nums);\n  }\n\n  public void update(int index, int val) {\n    binaryIndexedTree.update(index, val);\n  }\n\n  public int sumRange(int left, int right) {\n    return binaryIndexedTree.getSum(right) - binaryIndexedTree.getSum(left - 1);\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(index,val);\n * int param_2 = obj.sumRange(left,right);\n */
['Binary Indexed Tree', 'Java']