Skip to content

Commit 1f687bb

Browse files
fix build
1 parent 4de3643 commit 1f687bb

File tree

1 file changed

+10
-5
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+10
-5
lines changed

src/main/java/com/fishercoder/solutions/_149.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,24 +42,29 @@ public class _149 {
4242
*/
4343
public static class Solution1 {
4444
public int maxPoints(int[][] points) {
45-
if (points.length < 3) return points.length;
45+
if (points.length < 3) {
46+
return points.length;
47+
}
4648
int max = 0;
4749
Map<Long, Integer> map = new HashMap<>();
4850
for (int i = 0; i < points.length; i++) {
4951
int dup = 1;
5052
map.clear();
5153
for (int j = i + 1; j < points.length; j++) {
52-
int dx = points[j][0] - points[i][0], dy = points[j][1] - points[i][1];
53-
if (dx == 0 && dy == 0) dup++;
54-
else {
54+
int dx = points[j][0] - points[i][0];
55+
int dy = points[j][1] - points[i][1];
56+
if (dx == 0 && dy == 0) {
57+
dup++;
58+
} else {
5559
int gcd = getGcd(dx, dy);
5660
long slope = ((long) (dy / gcd) << 32) + (dx / gcd);
5761
map.put(slope, map.getOrDefault(slope, 0) + 1);
5862
}
5963
}
6064
max = Math.max(max, dup);
61-
for (Map.Entry<Long, Integer> entry : map.entrySet())
65+
for (Map.Entry<Long, Integer> entry : map.entrySet()) {
6266
max = Math.max(max, entry.getValue() + dup);
67+
}
6368
}
6469
return max;
6570
}

0 commit comments

Comments
 (0)