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

Commit9505287

Browse files
Create 1457.py
1 parent30a8395 commit9505287

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

‎1001-1500/1457.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Definition for a binary tree node.
2+
# class TreeNode:
3+
# def __init__(self, val=0, left=None, right=None):
4+
# self.val = val
5+
# self.left = left
6+
# self.right = right
7+
classSolution:
8+
defpseudoPalindromicPaths (self,root:Optional[TreeNode],cnt=0)->int:
9+
ifnotroot:return0
10+
cnt^=1<<(root.val-1)
11+
ifroot.leftisNoneandroot.rightisNone:
12+
return1ifcnt& (cnt-1)==0else0
13+
returnself.pseudoPalindromicPaths(root.left,cnt)+self.pseudoPalindromicPaths(root.right,cnt)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp