':type i: int
:type val: int
:rtype: int'

def update(self, i, val):

    def updateHelper(root, i, val):
        if ((not root) or (root.start > i) or (root.end < i)):
            return
        if ((root.start == i) and (root.end == i)):
            root.sum = val
            return
        updateHelper(root.left, i, val)
        updateHelper(root.right, i, val)
        root.sum = ((root.left.sum if root.left else 0) + (root.right.sum if root.right else 0))
    if (self.__nums[i] != val):
        self.__nums[i] = val
        updateHelper(self.__root, i, val)
