Skip to content

Commit cd29305

Browse files
authored
[20251210] PGM / Lv2 / 숫자의 표현 / 이강현
1 parent 176cc98 commit cd29305

File tree

1 file changed

+20
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)