본문 바로가기
Coding Test/Programmers

[Programmers] Lv 2. 롤케이크 자르기

by song.ift 2023. 2. 27.

https://school.programmers.co.kr/learn/courses/30/lessons/132265

 

프로그래머스

코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.

programmers.co.kr

 

javascript
닫기
function solution(topping) { ​​​​const [lDic, lSizeArr, rDic, rSizeArr] = [new Set(), [], new Set(), []]; ​​​​topping.forEach((el, idx) => { ​​​​​​​​lDic.add(el); ​​​​​​​​if (idx !== 0) rDic.add(topping.at(-idx)); ​​​​​​​​lSizeArr.push(lDic.size); ​​​​​​​​rSizeArr.push(rDic.size); ​​​​}); ​​​​return lSizeArr.reduce((acc, el, idx) => (el === rSizeArr.at(-idx - 1)) ? ++acc : acc, 0); }

GitHub : https://github.com/developeSHG/Algorithm-Baekjoon_Programmers/tree/main/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4/unrated/132265.%E2%80%85%EB%A1%A4%EC%BC%80%EC%9D%B4%ED%81%AC%E2%80%85%EC%9E%90%EB%A5%B4%EA%B8%B0

 

GitHub - developeSHG/Algorithm-Baekjoon_Programmers: 백준 and 프로그래머스 소스코드

백준 and 프로그래머스 소스코드. Contribute to developeSHG/Algorithm-Baekjoon_Programmers development by creating an account on GitHub.

github.com