Skip to content

Commit 89f92c9

Browse files
authored
Merge pull request #820 from Mark-777-0/main
Matching Leetcode 102 Answer Style
2 parents 5c47d03 + 55bef9b commit 89f92c9

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

python/104-Maximum-Depth-of-Binary-Tree.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@ def maxDepth(self, root: TreeNode) -> int:
2626
# BFS
2727
class Solution:
2828
def maxDepth(self, root: TreeNode) -> int:
29-
if not root:
30-
return 0
29+
q = deque()
30+
if root:
31+
q.append(root)
3132

3233
level = 0
33-
q = deque([root])
34+
3435
while q:
3536

3637
for i in range(len(q)):

0 commit comments

Comments
 (0)