Maximum Number of Achievable Transfer Requests
We have n buildings numbered from 0 to n - 1. Each building has a number of employees. It is transfer season, and some employees want to change the building they reside in.
You are given an array requests where requests[i] = [fromi, toi] represents an employee's request to transfer from building fromi to building toi.
All buildings are full, so a list of requests is achievable only if for each building, the net change in employee transfers is zero. This means the number of employees leaving is equal to the number of employees moving in.
Return the maximum number of achievable requests.
n = 5, requests = [[0,1],[1,0],[0,1],[1,2],[2,0],[3,4]]5n = 3, requests = [[0,0],[1,2],[2,1]]3Constraints
- 1 <= n <= 20
- 1 <= requests.length <= 16
- requests[i].length == 2
- 0 <= fromi, toi < n
Asked at 1 companies
Practice questions like this out loud in a mock coding interview with a live AI interviewer. First one free.