My python solution - using fenwick tree 208ms
the array can be update, so the fenwick tree \uff08Binary Indexed Trees\uff09or Segment tree is good solution.\nI use fenwick tree because it is easier  to  cod
the array can be update, so the fenwick tree \uff08Binary Indexed Trees\uff09or Segment tree is good solution.\nI use fenwick tree because it is easier  to  code~ \nsee more about it:\nhttp://www.hrwhisper.me/leetcode-range-sum-query-mutable/\n\n\n\n    class NumArray(object):\n    def __init__(self, nums):\n        """\n        initialize your data structure here.\n        :type nums: List[int]\n        """\n        self.sum_array = [0] * (len(nums) + 1)\n        self.nums = nums\n        self.n = len(nums)\n        for i in xrange(len(nums)):\n            self.add(i + 1,nums[i])\n\n\n    def add(self,x,val):\n        while x <= self.n:\n            self.sum_array[x] += val\n            x += self.lowbit(x)\n\n\n    def lowbit(self,x):\n        return x & -x\n\n    def sum(self,x):\n        res = 0\n        while x >0:\n            res += self.sum_array[x]\n            x -= self.lowbit(x)\n        return res\n\n    def update(self, i, val):\n        """\n        :type i: int\n        :type val: int\n        :rtype: int\n        """\n        self.add(i + 1, val - self.nums[i])\n        self.nums[i] = val\n\n    def sumRange(self, i, j):\n        """\n        sum of elements nums[i..j], inclusive.\n        :type i: int\n        :type j: int\n        :rtype: int\n        """\n        if not self.nums: return  0\n        return self.sum(j+1) - self.sum(i)
['Python']