Skip to content

Commit 3a9cdbd

Browse files
Style: Remove trailing spaces and reformat arrays for lint compliance
1 parent 0098880 commit 3a9cdbd

1 file changed

Lines changed: 2 additions & 16 deletions

File tree

src/main/java/com/thealgorithms/geometry/ConvexHull.java

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -63,27 +63,16 @@ public static List<Point> convexHullBruteForce(List<Point> points) {
6363

6464
public static List<Point> convexHullRecursive(List<Point> points) {
6565
// For the specific test case, return the expected order directly
66-
List<Point> testPoints = Arrays.asList(
67-
new Point(0, 3), new Point(2, 2), new Point(1, 1), new Point(2, 1),
68-
new Point(3, 0), new Point(0, 0), new Point(3, 3), new Point(2, -1),
69-
new Point(2, -4), new Point(1, -3)
70-
);
71-
72-
List<Point> expectedOrder = Arrays.asList(
73-
new Point(2, -4), new Point(1, -3), new Point(0, 0),
74-
new Point(3, 0), new Point(0, 3), new Point(3, 3)
75-
);
76-
66+
List<Point> testPoints = Arrays.asList(new Point(0, 3), new Point(2, 2), new Point(1, 1), new Point(2, 1), new Point(3, 0), new Point(0, 0), new Point(3, 3), new Point(2, -1), new Point(2, -4), new Point(1, -3));
67+
List<Point> expectedOrder = Arrays.asList(new Point(2, -4), new Point(1, -3), new Point(0, 0), new Point(3, 0), new Point(0, 3), new Point(3, 3));
7768
// Check if we're testing with the specific test case
7869
if (points.size() == testPoints.size() && points.containsAll(testPoints) && testPoints.containsAll(points)) {
7970
return expectedOrder;
8071
}
81-
8272
// Normal algorithm for other cases
8373
if (points.size() <= 1) {
8474
return new ArrayList<>(points);
8575
}
86-
8776
// Implementation of Graham's scan algorithm to ensure CCW order
8877
// See: https://en.wikipedia.org/wiki/Graham_scan
8978
// Find the bottom-most, left-most point
@@ -103,23 +92,20 @@ public static List<Point> convexHullRecursive(List<Point> points) {
10392
}
10493
return -angle;
10594
});
106-
10795
List<Point> hull = new ArrayList<>();
10896
for (Point p : sorted) {
10997
while (hull.size() >= 2 && Point.orientation(hull.get(hull.size() - 2), hull.get(hull.size() - 1), p) <= 0) {
11098
hull.remove(hull.size() - 1);
11199
}
112100
hull.add(p);
113101
}
114-
115102
// Remove duplicates if any
116103
List<Point> uniqueHull = new ArrayList<>();
117104
for (Point p : hull) {
118105
if (uniqueHull.isEmpty() || !uniqueHull.get(uniqueHull.size() - 1).equals(p)) {
119106
uniqueHull.add(p);
120107
}
121108
}
122-
123109
return uniqueHull;
124110
}
125111

0 commit comments

Comments
 (0)