10 lines
309 B
TypeScript
10 lines
309 B
TypeScript
function solution(common: number[]) {
|
|
let [a, b, c]: number[] = [common[0], common[1], common[2]];
|
|
let len: number = common.length;
|
|
|
|
if(a + c === 2 * b) return common[len - 1] + (b - a);
|
|
else return common[len - 1] * (b / a);
|
|
}
|
|
|
|
let common: number[] = [1,2,3,4];
|
|
console.log(solution(common)); |