Product
Pricing
Blog
Forum
NEW
Referral
Description
Solution
Discussion
Submissions
Ask AI
AI Insights
Quick Summary
Identify the maximum number of people that can be grouped together such that no two members know each other directly.
The input relationships form a connected tree structure with exactly n-1 edges and no cycles.
Requires making locally optimal inclusion or exclusion decisions for each person based on their immediate neighbors.
What This Tests
Tree dynamic programming
Graph traversal and state management
Recursive decomposition of subproblems
Iterative implementation to prevent stack overflow on deep trees
Common Patterns
Dynamic Programming
Graph Traversal
DFS/BFS
Collapse
Hint 1
Hint 2
Hint 3
What Interviewers May Ask Next
Report
Report seen similar question in interview
Ask AI Assistant
Ask AI Assistant
Ask me anything about this coding question!
python
Auto
Debug
Run
Submit
Test Cases
Input
Output
Expected