diff --git a/1544-count-good-nodes-in-binary-tree/1544-count-good-nodes-in-binary-tree.py b/1544-count-good-nodes-in-binary-tree/1544-count-good-nodes-in-binary-tree.py index 6ef260e..c46a9ca 100644 --- a/1544-count-good-nodes-in-binary-tree/1544-count-good-nodes-in-binary-tree.py +++ b/1544-count-good-nodes-in-binary-tree/1544-count-good-nodes-in-binary-tree.py @@ -7,11 +7,10 @@ class Solution: def goodNodes(self, root: TreeNode) -> int: return self.getGoodNodes(root, float("-inf")) - + def getGoodNodes(self, root: TreeNode, newMax: int) -> int: if not root: return 0 newMax = max(newMax, root.val) return (1 if root.val >= newMax else 0) + self.getGoodNodes(root.left, newMax) + self.getGoodNodes(root.right, newMax) - \ No newline at end of file