Movatterモバイル変換


[0]ホーム

URL:


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

Commit52d10e2

Browse files
add 1620
1 parent7aa3ac6 commit52d10e2

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ _If you like this project, please leave me a star._ ★
88

99
| # | Title | Solutions | Video | Difficulty | Tag
1010
|-----|----------------|---------------|--------|-------------|-------------
11+
|1620|[Coordinate With Maximum Network Quality](https://leetcode.com/problems/coordinate-with-maximum-network-quality/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1620.java)||Greedy|Medium|
1112
|1614|[Maximum Nesting Depth of the Parentheses](https://leetcode.com/problems/maximum-nesting-depth-of-the-parentheses/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1614.java)||Easy|String|
1213
|1609|[Even Odd Tree](https://leetcode.com/problems/even-odd-tree/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1609.java)||Medium|Tree|
1314
|1608|[Special Array With X Elements Greater Than or Equal X](https://leetcode.com/problems/special-array-with-x-elements-greater-than-or-equal-x/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1608.java)||Easy|Array|
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
packagecom.fishercoder.solutions;
2+
3+
publicclass_1620 {
4+
publicstaticclassSolution1 {
5+
publicstaticint[]bestCoordinate(int[][]towers,intradius) {
6+
intmaxSignal =0;
7+
int[]best =newint[2];
8+
for (inti =0;i <towers.length;i++) {
9+
intthisQuality =0;
10+
for (intj =0;j <towers.length;j++) {
11+
doubledistance =Math.sqrt((towers[i][0] -towers[j][0]) * (towers[i][0] -towers[j][0]) + (towers[i][1] -towers[j][1]) * (towers[i][1] -towers[j][1]));
12+
if (distance <=radius) {
13+
thisQuality +=Math.floor(towers[j][2] / (1 +distance));
14+
}
15+
}
16+
if (thisQuality >maxSignal) {
17+
maxSignal =thisQuality;
18+
best[0] =towers[i][0];
19+
best[1] =towers[i][1];
20+
}elseif (thisQuality ==maxSignal) {
21+
if (towers[i][0] <best[0]) {
22+
best[0] =towers[i][0];
23+
best[1] =towers[i][1];
24+
}elseif (towers[i][0] ==best[0] &&towers[i][1] <best[1]) {
25+
best[0] =towers[i][0];
26+
best[1] =towers[i][1];
27+
}
28+
}
29+
}
30+
returnbest;
31+
}
32+
}
33+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp