문제 나의 생각 Hint로 주어진 값을 보고 재귀 함수를 이용하여 답을 초기에 구현을 하였으나, 해당 값이 테스트를 통과하지 못함. 다른 방식을 찾아보는 도중 combination 함수를 이용한 방법으로 해결한 방식을 찾게 되었음. 나의 답안 public static int solution(int balls, int share) { return combination(balls, share); } public static int combination(int balls, int share) { if (share == 0 || balls== share){ return 1; }else { return combination(balls-1, share-1) + combination(balls-1, share); } }
문제 나의 생각 먼저 카운팅을 할 수 있는 배열을 만들고 난 후에, 입력되는 매개변수 기준으로 카운팅을 한다. 카운팅 된 값에서 가장 큰 값을 기준에 있는 인덱스를 가지고 있고, 가장 큰값을 똑같이 가진 인덱스가 있는지 한번 더 확인한다 라는 생각으로 접근 나의 답안 public static int solution(int[] array) { int[] a = new int[1000]; for (int i = 0; i < array.length; i++) { a[array[i]]++; } int answer = 0; int max = 0; for (int i = 0; i < a.length; i++) { if (max < a[i]) { answer = i; max = a[i]; } } int count =..