@@ -34,7 +34,7 @@ public long maxSubarrays(int n, int[][] conflictingPairs) {
3434 for (int i = n - 1; i >= 1; i--) {
3535 f[i] = Math.min(h[i], f[i + 1]);
3636 }
37- // calcXAndN (x) returns (n - x + 1) if x <= n, else 0.
37+ // forbiddenCount (x) returns (n - x + 1) if x <= n, else 0.
3838 // This is the number of forbidden subarrays starting at some i when f[i] = x.
3939 long originalUnion = 0;
4040 for (int i = 1; i <= n; i++) {
@@ -65,8 +65,8 @@ public long maxSubarrays(int n, int[][] conflictingPairs) {
6565 // For i = j, newF[j] = min( newCandidate, f[j+1] ) (which is newCandidate by
6666 // definition).
6767 int newFj = newCandidate;
68- // calcXAndN (x) is defined as (n - x + 1) if x<= n, else 0.
69- long delta = calcXAndN (newFj, n) - calcXAndN (f[j], n);
68+ // forbiddenCount (x) is defined as (n - x + 1) if x<= n, else 0.
69+ long delta = forbiddenCount (newFj, n) - forbiddenCount (f[j], n);
7070 int cur = newFj;
7171 // Now update backwards for i = j-1 down to 1.
7272 for (int i = j - 1; i >= 1; i--) {
@@ -75,7 +75,7 @@ public long maxSubarrays(int n, int[][] conflictingPairs) {
7575 if (newVal == f[i]) {
7676 break;
7777 }
78- delta += calcXAndN (newVal, n) - calcXAndN (f[i], n);
78+ delta += forbiddenCount (newVal, n) - forbiddenCount (f[i], n);
7979 cur = newVal;
8080 }
8181 long newUnion = originalUnion + delta;
@@ -85,7 +85,7 @@ public long maxSubarrays(int n, int[][] conflictingPairs) {
8585 return best;
8686 }
8787
88- private long calcXAndN (int x, int n) {
88+ private long forbiddenCount (int x, int n) {
8989 return x <= n ? (n - x + 1) : 0;
9090 }
9191}
0 commit comments