inblog logo
|
stupefyee
    알고리즘문제풀기

    [JAVA 문제 풀이] 277. 추억 점수

    프로그래머스 (176963)
    Stupefyee's avatar
    Stupefyee
    May 26, 2025
    [JAVA 문제 풀이] 277. 추억 점수
    Contents
    내가 작성한 코드
    school.programmers.co.kr
    https://school.programmers.co.kr/learn/courses/30/lessons/176963
    notion image
     

    내가 작성한 코드

    import java.util.*; class Solution { public int[] solution(String[] name, int[] yearning, String[][] photo) { int[] answer = new int[photo.length]; Map<String, Integer> nameToYearning = new HashMap<>(); // 이름에 해당하는 점수 저장 맵 // 이름과 점수 매핑 for(int i = 0; i < name.length; i++) { nameToYearning.put(name[i], yearning[i]); } // 각 사진 점수 계산 for(int i = 0; i < photo.length; i++) { int totalYearning = 0; for(String person : photo[i]) { // 해당 인물이 이름 목록에 있는지 확인하고 점수 합산 if(nameToYearning.containsKey(person)) { totalYearning += nameToYearning.get(person); } } answer[i] = totalYearning; } return answer; } }
    Share article
    Contents
    내가 작성한 코드

    stupefyee

    RSS·Powered by Inblog