Imagine a large corporate campus with n buildings numbered from 0 to n-1. It's transfer season, and employees want to move between buildings!
You're given an array of requests where each requests[i] = [from_i, to_i] represents an employee's request to transfer from building from_i to building to_i.
Here's the catch: all buildings are at full capacity. This means a set of transfer requests can only be approved if the net change for each building is zero - the number of employees leaving must equal the number moving in.
Goal: Find the maximum number of transfer requests that can be simultaneously approved while maintaining this balance constraint.
Example: If 2 employees leave building 0 and 1 leaves building 1, then exactly 2 must move to building 0 and 1 must move to building 1 for the transfers to be achievable.
Input & Output
Constraints
- 1 โค n โค 20
- 1 โค requests.length โค 16
- requests[i].length == 2
- 0 โค fromi, toi < n
- Small input size allows exponential solutions