프로그래머스 개인정보 수집 유효기간 - java


프로그래머스 개인정보 수집 유효기간 - java

예외케이스를 잘 다루어야 하는 문제이다. import java.util.*; class Solution { public int[] solution(String today, String[] terms, String[] privacies) { int[] answer = {}; // 개인정보 n개가 있습니다. // 모든 달은 28일까지 있다고 가정합니다. // 수집된 개인정보는 유효기간 전까지만 보관 가능하며, 유효기간이 지났다면 반드시 파기해야 합니다. //유효기간은 개인정보를 보관할 수 있는 달 수를 나타내는 정수이며, 1 이상 100 이하입니다. Map<String, Integer> termsMap = new HashMap<>(); for (String term : terms) { String[] termAndMonths = term.split(" "); termsMap.put(termAndMonths[0], Integer.parseInt(termAndMonths[1])); } //...



원문링크 : 프로그래머스 개인정보 수집 유효기간 - java