A code-review bot assigns reviewers to open pull requests. There are reviewers people numbered 0 to reviewers - 1 and prs pull requests numbered 0 to prs - 1. Each pair canReview[i] = [r, p] means reviewer r knows the code in pull request p.
Each reviewer can take at most one pull request, and each pull request needs at most one reviewer. Write maxAssignments(reviewers, prs, canReview) that returns the largest number of pull requests that can get a reviewer.
Input: reviewers = 3, prs = 3, canReview = [[0,0],[0,1],[1,0],[2,2]] Output: 3
Reviewer 0 takes PR 1, reviewer 1 takes PR 0, and reviewer 2 takes PR 2.
Input: reviewers = 3, prs = 1, canReview = [[0,0],[1,0],[2,0]] Output: 1
There's only one pull request, so only one assignment is possible.
1 <= reviewers, prs <= 1000 <= canReview.length <= reviewers * prsRun tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #482 Assign Reviewers to Pull Requests. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.