Python Segment Trees list implementation
Segment Tree implemented by list\n\n\nclass NumArray:\n\n    def __init__(self, nums: List[int]):\n        self.data = [0 for _ in nums] + nums\n        self.n 
Segment Tree implemented by list\n\n```\nclass NumArray:\n\n    def __init__(self, nums: List[int]):\n        self.data = [0 for _ in nums] + nums\n        self.n = len(nums)\n        \n        for idx in reversed(range(1, self.n)):\n            self.data[idx] = self.data[2*idx] + self.data[2*idx + 1]\n            \n    def update(self, i: int, val: int) -> None:\n        idx = i + self.n\n        self.data[idx] = val\n        while idx > 1:\n            idx //= 2\n            self.data[idx] = self.data[2*idx] + self.data[2*idx + 1]\n        \n\n    def sumRange(self, i: int, j: int) -> int:\n        #sum [i,j] = sum [i, j)\n        left = i + self.n\n        right = j + self.n +1\n        sum_range = 0\n        while left < right:\n            if left%2:\n                sum_range += self.data[left]\n                left +=1\n            if right %2:\n                right -= 1\n                sum_range += self.data[right]\n            left //= 2\n            right //= 2\n        \n        return sum_range\n```\nreference:\n1.[Video](http://https://www.youtube.com/watch?v=Oq2E2yGadnU)\n2.[python code](http://https://github.com/jakobkogler/Algorithm-DataStructures/blob/master/RangeQuery/SegmentTree.py)\n
[]