Skip to content

Commit 9589cef

Browse files
authored
[20250910] PGM / LV2 / 마법의 엘리베이터 / 김수연
[20250910] PGM / LV2 / 마법의 엘리베이터 / 김수연
2 parents 02a9618 + c88eccb commit 9589cef

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
```java
2+
class Solution {
3+
public int solution(int storey) {
4+
int answer = 0;
5+
while(storey > 0) {
6+
int temp = storey % 10;
7+
storey /= 10;
8+
9+
if (temp > 5) {
10+
answer += (10-temp);
11+
storey++;
12+
} else if (temp < 5) {
13+
answer += temp;
14+
} else if (storey % 10 >= 5) {
15+
answer += 5;
16+
storey++;
17+
} else {
18+
answer += 5;
19+
}
20+
}
21+
return answer;
22+
}
23+
}
24+
```

0 commit comments

Comments
 (0)