Leetcode 2872. Maximum Number of K-Divisible Components
Partition a tree by removing edges so every resulting component's node-sum is divisible by k, and return the maximum number of components. The core challenge is a tree DP / DFS problem computing subtree sums modulo k to decide where cuts can be made (greedy cuts on subtrees whose sum ≡ 0 mod k).
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
0
Hello Interview Premium
Your account is free and you can post anonymously if you choose.