728x90
SMALL

using System;

public class Solution {
    public int solution(int[] common) {
        int answer = 0;
        
        if(common[1]-common[0] == common[2]-common[1])
        {
            answer = common[common.Length-1]+common[1]-common[0];
        }
        else
        {
            answer = common[common.Length-1]*(common[1]/common[0]+common[1]%common[0]);
        }
        
        return answer;
    }
}

 

/////

 

자바

 

 

class Solution {
    public int solution(int[] common) {
        int answer = 0;

        int x = common[1] - common[0];
        int y = common[2] - common[1];

        if (x == y) 
        {
            answer = common[common.length - 1] + y;
        } 
        else 
        {
            answer = common[common.length - 1] * common[2] / common[1];
        }

        return answer;
    }
}

 

 

class Solution {
    public int solution(int[] common) {
        int answer = 0;

        if(common[1] - common[0] == common[2] - common[1])
        {
            answer = common[common.length-1] + (common[1] - common[0]);
        } 
        else 
            answer = common[common.length-1] * (common[1]/common[0]);

        return answer;
    }
}
728x90

설정

트랙백

댓글