Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitecf3ada

Browse files
Update 872.py
1 parent986350e commitecf3ada

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

‎501-1000/872.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,16 @@ def findLeaf(root):
1313
return [root.val]
1414
returnfindLeaf(root.left)+findLeaf(root.right)
1515
returnfindLeaf(root1)==findLeaf(root2)
16+
17+
18+
19+
classSolution:
20+
defleafSimilar(self,root1:Optional[TreeNode],root2:Optional[TreeNode])->bool:
21+
defdfs(root):
22+
ifnotroot:
23+
return []
24+
ifnotroot.leftandnotroot.right:
25+
return [root.val]
26+
returndfs(root.left)+dfs(root.right)
27+
returndfs(root2)==dfs(root1)
28+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp