FastPrepMaximum Programmer-Problem Matching
Problem · Graph

Maximum Programmer-Problem Matching

Learn this problem
MediumGoogle logoGoogleNEW GRADONSITE INTERVIEW
See Google hiring insights

Problem statement

Each problem has a list of tags, and each programmer has a list of skills. A programmer is compatible with a problem when the programmer's skills and the problem's tags share at least one identical string.

Match programmers to problems so that each programmer and each problem appears in at most one pair. Return the maximum possible number of compatible pairs.

Function

maximumProblemMatches(problemTags: List<List<String>>, programmerSkills: List<List<String>>) → int

Examples

Example 1

problemTags = [["java"], ["python", "sql"], ["go"]]programmerSkills = [["java", "python"], ["java"], ["rust", "go"]]return = 3

The first programmer can take the Python problem, the second programmer can take the Java problem, and the third programmer can take the Go problem. These three pairs use every programmer and problem once, so no larger matching is possible.

Example 2

problemTags = [["java"], ["python"], ["sql"]]programmerSkills = [["java", "python"], ["python"]]return = 2

Match the first programmer to the Java problem and the second programmer to the Python problem. Only two programmers are available, so the maximum is 2.

More Google problems

drafts saved locally
public int maximumProblemMatches(List<List<String>> problemTags, List<List<String>> programmerSkills) {
    // Write your code here.
}
problemTags[["java"], ["python", "sql"], ["go"]]
programmerSkills[["java", "python"], ["java"], ["rust", "go"]]
expected3
checking account