Round 1
Questions:
You are given a tree of n nodes and n-1 edges rooted at node 1. There is a values array of length n, where values[i] represents the number written on node (1-based indexing). You have to count the number of good edges in the tree.
An edge is considered good if you remove that edge from the tree and the tree splits into two subtrees such that there will be no subtree in which the frequency of any node value is more than k.
Constraint:
1 <= n <= 1e5
1 <= k, values[i] <= n
Sample Test Case:
- n=5, k=3
values = {1, 1, 1, 2, 1}
edges = {{1, 2}, {1, 3}, {2, 4}, {3, 5}}
Output: 3
Explanation: Good edges are {1, 2}, {1, 3}, and {3, 5}.
Candidate's Approach
No approach provided.
Interviewer's Feedback
No feedback provided.