2
public int maxPoints(int[][] points) {6
for (int i = 0; i < n; i++) {7
for (int j = i + 1; j < n; j++) {8
result = Math.max(result, getPoints(i, j, points));14
private int getPoints(int pt1, int pt2, int[][] points) {15
int[] point1 = points[pt1], point2 = points[pt2];16
double slope = (point1[1] - point2[1]) / (double) (point1[0] - point2[0]);18
for (int i = 0; i < points.length; i++) {19
if ((points[i][0] == point1[0] && points[i][1] == point1[1])20
|| (slope == Double.POSITIVE_INFINITY21
&& (point1[1] - points[i][1]) / (double) (point1[0] - points[i][0])22
== Double.POSITIVE_INFINITY)23
|| ((double) (point1[1] - points[i][1]) / (double) (point1[0] - points[i][0]) == slope))