Team Formation
Reported by candidates from Agoda's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Agoda asked this in May 2025 and it's a team-building constraint problem disguised as a pairing exercise. You've got candidates or employees, some attributes or skills, and rules about who can work together. The trap is thinking it's a simple matching problem when it's actually about finding valid subsets under constraints. StealthCoder will catch the edge cases if you freeze on the constraint logic during the live OA.
Pattern and pitfall
Team Formation is a constraint-satisfaction or graph-coloring variant. You're either partitioning people into valid groups, or selecting a team where every pair meets some condition. The pattern hinges on recognizing implicit constraints: incompatibilities, skill requirements, or balance rules. Most candidates brute-force combinations and time out. The real move is building an adjacency graph, checking which nodes can coexist, then using backtracking or greedy selection to maximize team size or count valid teams. If the problem's phrased as 'form M teams of N people each' you might need bipartite matching or flow. StealthCoder reads the exact wording and flags whether you need DFS, greedy, or dynamic programming on subsets.
Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.
You can drill Team Formation cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Agoda's OA.
Agoda reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Team Formation FAQ
Is this a graph problem or just recursion?+
Both. Model people as nodes, valid pairs as edges. Then use backtracking (recursion with pruning) to explore valid team configurations. If constraints are strict, you can model it as a matching or clique problem on the compatibility graph.
What's the trick Agoda is testing?+
They want to see if you recognize constraint satisfaction early and prune the search space. Most people enumerate all subsets blindly. You need to identify incompatible pairs upfront, then use that to cut branches in your backtracking.
How do I handle 'team size must be exactly N' vs 'at least N'?+
Exactly N is simpler: pick N people, validate all pairs. At least N means you might need to find the largest valid team, which is NP-hard. If time is tight, greedy or heuristic selection often passes in OAs.
Should I sort the input first?+
Usually yes. Sort by degree (how many valid teammates each person has) ascending. Start backtracking from low-degree nodes to prune faster. It won't change correctness but kills timeout.
Is there a DP approach?+
Only if the constraint graph has special structure (e.g., a tree or DAG). For general graphs, DP on subsets is exponential. Backtracking with memoization on state (used set) is your best bet for the live OA.