7ms Java solution using bottom up segment tree
A better way to construct segment tree using array instead of custom class. This approach came from Efficient and easy segment trees. It's really worth reading 
A better way to construct segment tree using array instead of custom class. This approach came from [Efficient and easy segment trees](http://codeforces.com/blog/entry/18051). It's really worth reading and give us a better idea of how to write a concise and efficient code.\n\n```java\npublic class NumArray {\n    int[] tree;\n    int n;\n\n    public NumArray(int[] nums) {\n        n = nums.length;\n        tree = new int[n << 1];\n        buildTree(nums);\n    }\n\n    private void buildTree(int[] nums) {\n        for (int i = n; i < n << 1; i++) {\n            tree[i] = nums[i - n];\n        }\n\n        for (int i = n - 1; i > 0; i--) {\n            tree[i] = tree[i << 1] + tree[i << 1 | 1];\n        }\n    }\n\n    void update(int i, int val) {\n        for (tree[i += n] = val; i > 0; i >>= 1) {\n            tree[i >> 1] = tree[i] + tree[i ^ 1];\n        }\n    }\n\n    public int sumRange(int i, int j) {\n        int ret = 0;\n        for (i += n, j += n; i <= j; i >>= 1, j >>= 1) {\n            if ((i & 1) == 1) ret += tree[i++];\n            if ((j & 1) == 0) ret += tree[j--];\n        }\n        return ret;\n    }\n}\n\n\n// Your NumArray object will be instantiated and called as such:\n// NumArray numArray = new NumArray(nums);\n// numArray.sumRange(0, 1);\n// numArray.update(1, 10);\n// numArray.sumRange(1, 2);\n```
[]