The Maximum Number of Accepted Invitations coding problem models a bipartite matching scenario: you have m boys and n girls, and a grid indicates which boy-girl pairs are compatible. Each boy can invite at most one girl, and each girl can accept at most one invitation. Maximize the total number of accepted invitations. This is the classic maximum bipartite matching problem.
Uber, Google, and Bloomberg include this problem because maximum bipartite matching is a fundamental graph algorithm. It tests knowledge of augmenting paths via DFS (the standard matching algorithm used in interviews). While advanced algorithms like Hopcroft-Karp exist, the simpler augmenting path DFS is the expected approach here, and it runs in O(m * n) for dense bipartite graphs.
Augmenting path DFS (Hungarian-style matching): For each boy, try to find an augmenting path — a path from this boy through alternating unmatched/matched edges to a free girl. Maintain a match array tracking which boy each girl is currently matched to. For each unmatched boy, run DFS: try each compatible girl; if she's free, match them; if she's matched to another boy, recursively try to re-route that boy. The total matches found is the answer.
Time: O(m * n) per augmenting path × m boys = O(m² * n) worst case, acceptable for typical constraints.
Boys: 2, Girls: 3. Grid: [[1,1,0],[0,1,1]]
If grid were [[1,1,0],[1,0,0]]:
For the Array Matrix Graph Depth-First Search interview pattern, implement the augmenting path matching algorithm cleanly: tryMatch(boy, visited) returns true if an augmenting path exists. Call it for each unmatched boy. The visited array prevents re-checking the same girl in one augmentation. This template solves all bipartite matching problems encountered in interviews.
| Title | Difficulty | Topics | LeetCode |
|---|---|---|---|
| Battleships in a Board | Medium | Solve | |
| Minimum Operations to Remove Adjacent Ones in Matrix | Hard | Solve | |
| Minimum Time to Break Locks II | Hard | Solve | |
| Pacific Atlantic Water Flow | Medium | Solve | |
| The Maze | Medium | Solve |