INDEX
![](https://blog.kakaocdn.net/dn/m2Ng4/btstX6Q6LVw/eowlR88pghXkCNBFpdsH8K/img.png)
https://school.programmers.co.kr/learn/courses/30/lessons/150370
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
Solution
주어지는 오늘 날짜와 계약한 날짜의 차이를 구해서 약관기한보다 초과된 계약번호를 return
하면 됩니다.
문제에서 모든 달은 28일까지 있다고 강력한
힌트를 주었습니다.
그럼 오늘 날짜를 일로 환산하고 계약일자를 일자로 환산해서 이 둘의 차이를 약관기한 * 28 과 비교하면 됩니다.
function solution(today, terms, privacies) {
let termsMap = {};
terms.map((item)=>{
const [type, expire] = item.split(' ');
termsMap[type] = expire;
})
let answer = [];
for(let i=0; i<privacies.length; i++){
const [date, type] = privacies[i].split(' ');
const [year, month, day] = date.split('.');
const [t_year, t_month, t_day] = today.split('.');
let trans_t_day = Number(t_year) * 12 * 28 + Number(t_month) * 28 + Number(t_day);
let trans_day = Number(year) * 12 * 28 + Number(month) * 28 + Number(day);
trans_t_day - trans_day >= termsMap[type]*28 ? answer.push(i+1) : "";
}
return answer;
}
728x90
'알고리즘 스터디' 카테고리의 다른 글
[Programmers] 기사단원의 무기 - Javascript (0) | 2023.09.24 |
---|---|
2022 KAKAO TECH INTERNSHIP - 성격 유형 검사하기 (0) | 2023.09.13 |
[Python] BOJ 2004 조합 0의 개수 (0) | 2021.07.21 |
[JAVA] BOJ 9375 패션왕 김해빈 (0) | 2021.07.21 |
[Python] BOJ 1010 다리놓기 (0) | 2021.07.20 |