랄라
LV2 - 멀리뛰기 본문
https://school.programmers.co.kr/learn/courses/30/lessons/12914#qna
프로그래머스
SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프
programmers.co.kr
*답변
더보기
class Solution {
public long solution(int n) {
long answer = 0;
int mod = 1234567;
long[] counter = new long[n+1];
counter[0] = 0;
counter[1] = 1;
if(n > 1){
counter[2] = 2;
}
for(int i=3; i<=n;i++){
counter[i] = (counter[i-1] + counter[i-2]) %mod;
}
answer = counter[n];
return answer;
}
}
'스터디 > 코딩 테스트(프로그래머스)' 카테고리의 다른 글
| LV2. 다음 큰 숫자 (0) | 2025.02.17 |
|---|---|
| LV1 정수 내림차순으로 배치하기 - JAVA (1) | 2024.12.19 |
| LV1 이름이 없는 동물의 아이디 - SQL (2) | 2024.12.19 |
| LV1 조건에 맞는 회원수 구하기 - SQL (0) | 2024.12.18 |
| LV1 예산 - JAVA (1) | 2024.12.18 |