Untitled
unknown
plain_text
a year ago
386 B
3
Indexable
class Solution(object): def goodNodes(self, root): """ :type root: TreeNode :rtype: int """ def count(node, rmax): if node: rmax = max(rmax, node.val) return (1 if node.val >= rmax else 0) + count(node.left, rmax) + count(node.right, rmax) return 0 return count(root, root.val)
Editor is loading...
Leave a Comment