@@ -34,7 +34,7 @@ public long maxSubarrays(int n, int[][] conflictingPairs) {
34
34
for (int i = n - 1 ; i >= 1 ; i --) {
35
35
f [i ] = Math .min (h [i ], f [i + 1 ]);
36
36
}
37
- // calcXAndN (x) returns (n - x + 1) if x <= n, else 0.
37
+ // forbiddenCount (x) returns (n - x + 1) if x <= n, else 0.
38
38
// This is the number of forbidden subarrays starting at some i when f[i] = x.
39
39
long originalUnion = 0 ;
40
40
for (int i = 1 ; i <= n ; i ++) {
@@ -65,8 +65,8 @@ public long maxSubarrays(int n, int[][] conflictingPairs) {
65
65
// For i = j, newF[j] = min( newCandidate, f[j+1] ) (which is newCandidate by
66
66
// definition).
67
67
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 );
70
70
int cur = newFj ;
71
71
// Now update backwards for i = j-1 down to 1.
72
72
for (int i = j - 1 ; i >= 1 ; i --) {
@@ -75,7 +75,7 @@ public long maxSubarrays(int n, int[][] conflictingPairs) {
75
75
if (newVal == f [i ]) {
76
76
break ;
77
77
}
78
- delta += calcXAndN (newVal , n ) - calcXAndN (f [i ], n );
78
+ delta += forbiddenCount (newVal , n ) - forbiddenCount (f [i ], n );
79
79
cur = newVal ;
80
80
}
81
81
long newUnion = originalUnion + delta ;
@@ -85,7 +85,7 @@ public long maxSubarrays(int n, int[][] conflictingPairs) {
85
85
return best ;
86
86
}
87
87
88
- private long calcXAndN (int x , int n ) {
88
+ private long forbiddenCount (int x , int n ) {
89
89
return x <= n ? (n - x + 1 ) : 0 ;
90
90
}
91
91
}
0 commit comments