Max Value of Equation LeetCode solution in Java

1
class Solution {
2
public int findMaxValueOfEquation(int[][] points, int k) {
3
int ans = Integer.MIN_VALUE;
4
int i = 0;
5
int f = 1;
6
while (i < points.length) {
7
if (f < i + 1) f = i + 1;
8
for (int j = f; j <= points.length - 1; j++) {
9
if (points[j][0] > (points[i][0] + k)) break;
10
if ((points[i][1] + points[j][1] + points[j][0] - points[i][0]) > ans) {
11
ans = points[i][1] + points[j][1] + points[j][0] - points[i][0];
12
f = j - 1;
13
}
14
}
15
i++;
16
}
17
return ans;
18
}
19
}

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0