Skip to content

Commit d7b6f82

Browse files
authored
[20251206] PGM / Lv2 / 숫자의 표현 / 이종환
1 parent 0cffed4 commit d7b6f82

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
```java
2+
import java.io.*;
3+
import java.util.*;
4+
5+
class Solution {
6+
public int solution(int n) {
7+
int start = 1;
8+
int end = 1;
9+
int curSum = 1;
10+
11+
int answer = 0;
12+
13+
while (end <= n){
14+
if (curSum == n){
15+
answer++;
16+
end++;
17+
curSum += end;
18+
}else if (curSum < n){
19+
end++;
20+
curSum += end;
21+
}else{
22+
curSum -= start;
23+
start++;
24+
}
25+
}
26+
return answer;
27+
}
28+
}
29+
```

0 commit comments

Comments
 (0)