1457. Pseudo-Palindromic Paths in a Binary Tree
1457. Pseudo-Palindromic Paths in a Binary Tree
Description
Given a binary tree where node values are digits from 1 to 9. A path in the binary tree is said to be pseudo-palindromic if at least one permutation of the node values in the path is a palindrome.
Return the number of pseudo-palindromic paths going from the root node to leaf nodes.
Example 1:
![](https://assets.leetcode.com/uploads/2020/05/06/palindromic_paths_1.png)
1 | Input: root = [2,3,1,3,1,null,1] |
Example 2:
1 | Input: root = [2,1,1,1,3,null,null,null,null,null,1] |
Example 3:
1 | Input: root = [9] |
Constraints:
- The number of nodes in the tree is in the range
[1, 10^5]
. 1 <= Node.val <= 9
Hints/Notes
- traverse the tree
Solution
Language: C++
1 | /** |