프로그래머스 LV0 > 코딩테스트 입문 > 다음에 올 숫자
문제 : https://school.programmers.co.kr/learn/courses/30/lessons/120924
function solution(common) {
let cha = []
let be = []
for(let i =0; i<common.length-1; i++){
cha.push(common[i+1] - common[i]);
be.push(common[i+1] / common[i]);
}
const setCha = [...new Set(cha)];
const setBe = [...new Set(be)];
return setCha.length == 1 ?
common[common.length-1] + setCha[0] :
common[common.length-1] * setBe[0]
}반응형
'[Develop] 개발공부 > FE - 프론트엔드' 카테고리의 다른 글
| [LV0] 문자열 밀기 (0) | 2022.11.28 |
|---|---|
| [LV0] 종이 자르기 (0) | 2022.11.26 |
| [LV1] 소수 찾기 / Math.sqrt() 제곱근 활용 (0) | 2022.11.24 |
| [LV1] 숫자 짝꿍 (0) | 2022.11.24 |
| [LV0] 숨어있는 숫자의 덧셈(2) (0) | 2022.11.23 |