[Programmers_CT] 14. 가채점

문정준's avatar
Feb 11, 2025
[Programmers_CT] 14. 가채점
💡
프로그래머스 코딩 테스트 14. 가채점

1. 문제 설명 - 디버깅

notion image

제한 사항

notion image

2. 입출력 예시

notion image

3. 코드 수정

class Solution { public String[] solution(int[] numbers, int[] our_score, int[] score_list) { int num_student = numbers.length; String[] answer = new String[num_student]; for (int i = 0; i < num_student; i++) { if (our_score[i] == score_list[numbers[i]-1]) { answer[i] = "Same"; } else { answer[i] = "Different"; } } return answer; } }
  • 2번째 예시를 보았을 때, 85점은 3번 학생이 예측한 점수, 93점은 4번 학생이 예측한 점수
    • score_list의 3번째 점수는 38점으로 85점과 다름
      • 3번째 점수는 score_list[2]에 저장
    • score_list의 4번째 점수는 93점으로 같음
      • 4번째 점수는 score_list[3]에 저장
    • 즉, score_list의 index는 numbers의 값 - 1로 찾아야 함
  • 정답 : our_score[i] == score_list[numbers[i]-1]
 

4. 테스트 실행

notion image

5. 제출 후 채점

notion image
 
Share article

sxias