Skip to content

Commit 2ed80e8

Browse files
committed
Runtime: 48 ms (Top 45.59%) | Memory: 42 MB (Top 92.59%)
1 parent bab1fdb commit 2ed80e8

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

scripts/algorithms/M/Max Points on a Line/Max Points on a Line.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Runtime: 48 ms (Top 45.59%) | Memory: 42 MB (Top 92.59%)
12
class Solution {
23
public int maxPoints(int[][] points) {
34
int n = points.length;
@@ -15,11 +16,11 @@ private int getPoints(int pt1, int pt2, int[][] points){
1516
double slope = (point1[1] - point2[1])/(double)(point1[0] - point2[0]);
1617
int result = 0;
1718
for(int i = 0; i<points.length; i++){
18-
if((points[i][0] == point1[0] && points[i][1] == point1[1]) ||
19-
(slope == Double.POSITIVE_INFINITY && (point1[1] - points[i][1])/(double)(point1[0] - points[i][0]) == Double.POSITIVE_INFINITY) ||
20-
((double)(point1[1] - points[i][1])/(double)(point1[0] - points[i][0]) == slope))
19+
if((points[i][0] == point1[0] && points[i][1] == point1[1]) ||
20+
(slope == Double.POSITIVE_INFINITY && (point1[1] - points[i][1])/(double)(point1[0] - points[i][0]) == Double.POSITIVE_INFINITY) ||
21+
((double)(point1[1] - points[i][1])/(double)(point1[0] - points[i][0]) == slope))
2122
result++;
2223
}
2324
return result;
2425
}
25-
}
26+
}

0 commit comments

Comments
 (0)