Pseudo-Palindromic Paths in a Binary Tree
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
2
/ \
3 1
/ \ \
3 1 1Input
root = [2,3,1,3,1,null,1]Output
2There are three root-to-leaf paths, and only
[2,3,3] and [2,1,1] can be rearranged into palindromes.Example 2
2
/ \
1 1
/ \
1 3
\
1Input
root = [2,1,1,1,3,null,null,null,null,null,1]Output
1There are three root-to-leaf paths, and only
[2,1,1] can be rearranged into a palindrome.Constraints
- The number of nodes in the tree is in the range
[1, 10^5]. 1 <= Node.val <= 9