Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1a92c96

Browse files
committed
Update Solution.java
1 parent ed1b7c3 commit 1a92c96

File tree

1 file changed

+5
-12
lines changed
  • solution/1400-1499/1453.Maximum Number of Darts Inside of a Circular Dartboard

1 file changed

+5
-12
lines changed

‎solution/1400-1499/1453.Maximum Number of Darts Inside of a Circular Dartboard/Solution.java‎

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
import java.util.*;
2-
3-
public class Solution {
1+
class Solution {
42
public int numPoints(int[][] darts, int r) {
53
int n = darts.length;
64
int maxDarts = 1;
75

86
for (int i = 0; i < n; i++) {
97
for (int j = i + 1; j < n; j++) {
10-
List<double[]> centers = possibleCenters(darts[i][0], darts[i][1], darts[j][0], darts[j][1], r);
8+
List<double[]> centers
9+
= possibleCenters(darts[i][0], darts[i][1], darts[j][0], darts[j][1], r);
1110
for (double[] center : centers) {
1211
maxDarts = Math.max(maxDarts, countDarts(center[0], center[1], darts, r));
1312
}
@@ -30,8 +29,8 @@ private List<double[]> possibleCenters(int x1, int y1, int x2, int y2, int r) {
3029
double offsetX = distToCenter * dy / d;
3130
double offsetY = distToCenter * -dx / d;
3231

33-
centers.add(new double[]{midX + offsetX, midY + offsetY});
34-
centers.add(new double[]{midX - offsetX, midY - offsetY});
32+
centers.add(new double[]{midX + offsetX, midY + offsetY});
33+
centers.add(new double[]{midX - offsetX, midY - offsetY});
3534
return centers;
3635
}
3736

@@ -44,10 +43,4 @@ private int countDarts(double x, double y, int[][] darts, int r) {
4443
}
4544
return count;
4645
}
47-
48-
public static void main(String[] args) {
49-
Solution solution = new Solution();
50-
System.out.println(solution.numPoints(new int[][]{{-2,0},{2,0},{0,2},{0,-2}}, 2)); // Output: 4
51-
System.out.println(solution.numPoints(new int[][]{{-3,0},{3,0},{2,6},{5,4},{0,9},{7,8}}, 5)); // Output: 5
52-
}
5346
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /