answer
to 0
to store the maximum number of requests that can be considered.indegree
of size n
with all values as 0
to track the net change in employee count for each building.indegree
are zero. If so, update answer
with the maximum of answer
and count
.
b. If the current request is included, update indegree
for the involved buildings and recursively call the function with the next index and count + 1
.
c. Backtrack by reverting changes in indegree
.
d. Recursively call the function with the next index without including the current request.answer
as the maximum number of achievable requests.