728x90
반응형
문제
반응형
풀이
1
2
3
4
5
6
7
8
9
10
11
|
class Solution {
public int solution(int[] common) {
int answer=0;
if(common[2]-common[1]==common[1]-common[0]){ //등차수열일경우
answer=common[common.length-1]+common[1]-common[0];
}else{ //등비수열일경우
answer=common[common.length-1]*common[1]/common[0];
}
return answer;
}
}
|
cs |
728x90
반응형
'[JAVA] 프로그래머스 스쿨 > Java Lv.0' 카테고리의 다른 글
[프로그래머스/Java] Lv.0 flag에 따라 다른 값 반환하기 (0) | 2023.12.24 |
---|---|
[프로그래머스/Java] Lv.0 옹알이 (1) (0) | 2023.01.03 |
[프로그래머스/Java] Lv.0 종이 자르기 (0) | 2023.01.03 |
[프로그래머스/Java] Lv.0 문자열 밀기 (0) | 2023.01.02 |
[프로그래머스/Java] Lv.0 잘라서 배열로 저장하기 (0) | 2023.01.02 |