목록Java (3)
해뜰날
체육복 처음 푼 풀이 import java.util.ArrayList; import java.util.Arrays; class Solution { public int solution(int n, int[] lost, int[] reserve) { int[] clothes = new int[n]; Arrays.fill(clothes, 1); //체육복 갯수 1로 초기화 for(int i : lost) { clothes[i-1]--; } //잃어버린 학생들은 하나 더 줄인다 for(int i : reserve) { clothes[i-1]++; } //여유 있는 애들은 하나 더 늘린다 int answer = 0; for(int i=0; i
모의고사 처음 푼 풀이 class Solution { public int[] solution(int[] answers) { int[] std1 = {1,2,3,4,5}; int[] std2 = {2,1,2,3,2,4,2,5}; int[] std3 = {3,3,1,1,2,2,4,4,5,5}; int std1Num = 0; int std2Num = 0; int std3Num = 0; for(int i=0; i
완주하지 못한 선수 처음 푼 풀이 import java.util.Arrays; class Solution { public String solution(String[] participant, String[] completion) { Arrays.sort(participant); Arrays.sort(completion); for(int i=0 ; i 인자로 넘어온 객체: return 양수 */ 2) 실수한 부분 처음에 아래와 같이 풀다가 indexoutofbound(?) 에러 발생함 for(int i=0 ; i