Segment Tree TLE, can this be optimised further?
Approach\nSegment Tree TLE, can this be optimised further?\n\n# Code\n\nclass SegNode:\n    def __init__(self, start: int, end: int, value: int):\n        self.
# Approach\nSegment Tree TLE, can this be optimised further?\n\n# Code\n```\nclass SegNode:\n    def __init__(self, start: int, end: int, value: int):\n        self.start = start\n        self.end = end\n        self.value = value\n        self.left = self.right = None\n    \n    def __str__(self) -> str:\n        return f\'{self.start}-{self.end} : {self.value} [{self.left}] ({self.right})\'\n    \n    def get(self, x: int) -> int:\n        if not self.left:\n            return max(self.value, x - self.start)\n        if x == self.left.end:\n            return self.right.value\n        if x < self.left.end:\n            return self.left.get(x)\n        else:\n            return self.right.get(x)\n    \n    def update(self, v: int) -> int:\n        if self.value == v or v == -1:\n            return -1\n        self.value = v\n        if self.left:\n            return self.right.update(self.left.update(v))\n        return max(self.end - self.start, self.value)\n    \n    def add(self, x: int, v:int=0) -> int:\n        if not self.left:\n            self.left = SegNode(self.start, x, v)\n            self.right = SegNode(x, self.end, max(x - self.start, v))\n            return max(self.right.end - self.right.start, self.right.value)\n        if x < self.left.end:\n            return self.right.update(self.left.add(x, v))\n        else:\n            return self.right.add(x, max(v, self.right.value))\n\nclass Solution:\n    def getResults(self, queries: List[List[int]]) -> List[bool]:\n        MAX_SIZE = min(5*(10**4), 3*len(queries))\n        tree = SegNode(0, MAX_SIZE, 0)\n        r = []\n        for q in queries:\n            match q[0]:\n                case 1:\n                    tree.add(q[1])\n                case 2:\n                    r.append(tree.get(q[1]) >= q[2])\n        return r\n```
['Segment Tree', 'Python3']