We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 29c05d4 commit 79c3512Copy full SHA for 79c3512
1 file changed
lkhyun/202511/22 PGM Lv2 기지국 설치.md
@@ -0,0 +1,26 @@
1
+```java
2
+class Solution {
3
+ public int solution(int n, int[] stations, int w) {
4
+ int answer = 0;
5
+
6
+ int idx = 1;
7
+ for(int station : stations){
8
+ if(idx < station - w){
9
+ answer += install(idx,station-w-1,w);
10
+ }
11
+ idx = station+w+1;
12
+ if(station+w >= n) break;
13
14
+ if(idx <= n){
15
+ answer += install(idx,n,w);
16
17
18
+ return answer;
19
20
+ public int install(int start, int end, int w){
21
+ int range = end - start + 1;
22
+ int size = w*2 + 1;
23
+ return range%size != 0 ? range/size + 1 : range/size;
24
25
+}
26
+```
0 commit comments