Mentor Mentee Matching Problem

Mentor Mentee Matching Problem — ExecCode Hard DSA Practice

Solve the Mentor Mentee Matching problem on ExecCode. Free online hard DSA practice in Graph. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Left: mentors. Right: mentees. An edge means they can work together. Maximum number of pairs with each person used at most once is bipartite matching. Hopcroft–Karp is the fast contest version; DFS augmenting paths are enough for small instances. Return the size of a maximum matching. Left nodes are 0..nleft-1, right 0..nright-1. You are given: nleft — mentors nright — mentees edges — [mentor, mentee] Return matching size. A star can match only one edge.

Examples

Input {'nleft': 3, 'nright': 2, 'edges': [[0, 0], [1, 0], [1, 1], [2, 1]]}; Output 2. Input {'nleft': 1, 'nright': 1, 'edges': []}; Output 0. Input {'nleft': 2, 'nright': 2, 'edges': [[0, 0], [0, 1], [1, 0], [1, 1]]}; Output 2

Constraints

Multiple edges to the same pair still count as one possible seat Isolated people match 0

Practice Mentor Mentee Matching free on ExecCode. Browse DSA problems, topic map, and placement guides.