-
프로그래머스 LV1 - 로또의 최고 순위와 최저 순위STUDY/ALGORITHM 2025. 2. 9. 17:59
갑자기 난이도가 뚝 떨어졌다.
그 이유는 내가 책에서 추천해주는 문제를 순차적으로 풀고있기 때문이다.
책 이름은 "코딩 테스트 합격자되기 (자바편)".
이번 문제는 확실히 레벨만큼 쉬웠다.
class Solution { public int[] solution(int[] lottos, int[] win_nums) { List<Integer> winNumsList = Arrays.stream(win_nums).boxed().collect(Collectors.toList()); int zeroCount = 0; int correctCount = 0; for (int num : lottos) { if(num == 0) zeroCount++; if(winNumsList.contains(num)) correctCount++; } int[] answer = new int[]{ getPrice(correctCount + zeroCount), getPrice(correctCount) }; return answer; } private int getPrice(final int correctCount){ return Math.min(7 - correctCount, 6); } }확실히 쉬웠던 만큼 성취감이 크지 않았다.
그래도 하나 안 사실이 잇는데,
Arrays.stream(win_nums).boxed().toList(); 가 프로그래머스에선 안되더라.
보아하니 프로그래머스 자바 버전은 16버전 이하인것 같다.
(찾아보니 14버전 이었다.)'STUDY > ALGORITHM' 카테고리의 다른 글
프로그래머스 LV2 - 지게차와 크레인 (0) 2025.02.11 프로그래머스 LV2 - 충돌위험 찾기 (0) 2025.02.10 프로그래머스 LV2 - 퍼즐 게임 챌린지 (1) 2025.02.10 프로그래머스 LV3 - 파괴되지 않은 건물 (0) 2025.02.09 프로그래머스 LV3 - 보석쇼핑 (0) 2025.01.31