Search
⌘K

Leetcode 3575. Maximum Good Subtree Score

For each node in a rooted tree, find the maximum sum of a subset of nodes in its subtree such that across the chosen nodes each decimal digit 0–9 appears at most once, then return the sum of all these per-node maxima modulo 1e9+7. The core challenge is a tree DP that merges children using 10-bit masks (2^10 states) representing used digits and discards nodes whose own value has repeated digits.


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.