[Version]
⦁ 2024.04.03 / [Algorithm / Programmers] 숫자의 표현
class Solution {
public int solution(int n) {
int totalCount = 0;
for (int i = 1; i <= n; i++) {
int sum = 0;
for (int j = i; j <= n; j++) {
sum += j;
if (sum == n) {
totalCount++;
break;
}
if (sum > n) {
break;
}
}
}
return totalCount;
}
}
'Algorithm > 프로그래머스' 카테고리의 다른 글
[Algorithm / Programmers] 2023 KAKAO BLIND RECRUITMENT-개인정보 수집 유효기간 (0) | 2024.04.03 |
---|---|
[Algorithm / Programmers] 달리기 경주 (0) | 2024.04.03 |
[Algorithm / Programmers] 다음 큰 숫자 (0) | 2024.04.03 |
[Algorithm / Programmers] 2019 카카오 개발자 겨울 인턴십 - 크레인 인형뽑기 게임 (0) | 2024.04.02 |
[Algorithm / Programmers] 2020 카카오 인턴십 키패드 누르기 (0) | 2024.04.02 |