본문으로 바로가기
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
반응형