Skip to content

Commit d14d591

Browse files
authored
[20250911] PGM / LV2 / 시소 짝꿍 / 김수연
[20250911] PGM / LV2 / 시소 짝꿍 / 김수연
2 parents a5c87aa + 8b224b0 commit d14d591

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
```java
2+
import java.util.*;
3+
class Solution {
4+
public long solution(int[] weights) {
5+
long answer = 0;
6+
Arrays.sort(weights);
7+
Map<Double, Integer> map = new HashMap<>();
8+
for(int i : weights) {
9+
double a = i*1.0;
10+
double b = (i*2.0)/3.0;
11+
double c = (i*1.0)/2.0;
12+
double d = (i*3.0)/4.0;
13+
if(map.containsKey(a)) answer += map.get(a);
14+
if(map.containsKey(b)) answer += map.get(b);
15+
if(map.containsKey(c)) answer += map.get(c);
16+
if(map.containsKey(d)) answer += map.get(d);
17+
map.put((i*1.0), map.getOrDefault((i*1.0), 0)+1);
18+
}
19+
20+
return answer;
21+
}
22+
}
23+
```

0 commit comments

Comments
 (0)