Skip to content

Commit 0c3bae9

Browse files
committed
Time: 309 ms (88.33%), Space: 50.8 MB (51.67%) - LeetHub
1 parent 53b09c7 commit 0c3bae9

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

1973-count-nodes-equal-to-sum-of-descendants/1973-count-nodes-equal-to-sum-of-descendants.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# time complexity: O(n)
2+
# space complexity: O(n)
13
from typing import Optional
24

35

@@ -22,7 +24,7 @@ def countNodes(node: Optional[TreeNode]) -> int:
2224
if left + right == node.val:
2325
count += 1
2426
return node.val + left + right
25-
27+
2628
countNodes(root)
2729
return count
2830

0 commit comments

Comments
 (0)