class Solution:
def __init__(self):
self.count = 0
def countNodes(self, root: TreeNode) -> int:
self.helper(root)
return self.count
def helper(self, root):
if root is None:
return
self.count += 1
self.countNodes(root.left)
self.countNodes(root.right)
leetcode222. Count Complete Tree Nodes
猜你喜欢
转载自blog.csdn.net/weixin_36149892/article/details/98113487
今日推荐
周排行