Skip to content

Practice Pseudo-Palindromic Paths in a Binary Tree

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#1457
LeetCode Problem

Pseudo-Palindromic Paths in a Binary Tree

Problem Statement

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.

Source: Pseudo-Palindromic Paths in a Binary Tree on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
root = [2,3,1,3,1,null,1]
Output
2

# Example 2

Input
root = [2,1,1,1,3,null,null,null,null,null,1]
Output
1

# Example 3

Input
root = [9]
Output
1

Constraints

The number of nodes in the tree is in the range [1, 10^5].
1 <= Node.val <= 9

Related LeetCode Problems

Practice more problems similar to Pseudo-Palindromic Paths in a Binary Tree.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.