Skip to content

Commit f8bc395

Browse files
committed
Runtime: 35 ms (Top 65.52%) | Memory: 42.2 MB (Top 56.90%)
1 parent e6a6af4 commit f8bc395

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
// Runtime: 35 ms (Top 65.52%) | Memory: 42.2 MB (Top 56.90%)
12
class Solution {
23
int max = 0;
34
public int maximumRequests(int n, int[][] requests) {
45
helper(requests, 0, new int[n], 0);
56
return max;
67
}
7-
8+
89
private void helper(int[][] requests, int index, int[] count, int num) {
910
// Traverse all n buildings to see if they are all 0. (means balanced)
1011
if (index == requests.length) {
@@ -16,14 +17,14 @@ private void helper(int[][] requests, int index, int[] count, int num) {
1617
max = Math.max(max, num);
1718
return;
1819
}
19-
// Choose this request
20+
// Choose this request
2021
count[requests[index][0]]++;
2122
count[requests[index][1]]--;
2223
helper(requests, index + 1, count, num + 1);
2324
count[requests[index][0]]--;
2425
count[requests[index][1]]++;
25-
26-
// Not Choose the request
26+
27+
// Not Choose the request
2728
helper(requests, index + 1, count, num);
2829
}
2930
}

0 commit comments

Comments
 (0)