Search
⌘K

Leetcode 2791. Count Paths That Can Form a Palindrome in a Tree

Count pairs of nodes in a rooted tree whose path edge-letters can be rearranged into a palindrome — equivalently, the multiset of letters on the path has at most one character with odd count. This reduces to comparing parity bitmasks of root-to-node letter counts: pairs with equal masks or masks differing by one bit form valid paths.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.