Convert BST to Greater Tree Solutions in PythonNumber 538Difficulty EasyAcceptance 55.4%Link LeetCodeOther languages —SolutionsPython solution by haoel/leetcode""" since this is a BST, we can do a inorder traversal (inversed, from right to left), during this process, track the sum and update the node.val """ class Solution: def convertBST(self, root): self.total = 0 def helper(node): if not node: return helper(node.right) node.val += self.total self.total = node.val helper(node.left) helper(root) return root"""since this is a BST, we can do a inorder traversal (inversed, from right to left),during this process, track the sum and update the node.val"""class Solution: def convertBST(self, root): self.total = 0 def helper(node): if not node: return helper(node.right) node.val += self.total self.total = node.val helper(node.left) helper(root) return root