[프로그래머스/Java] 모의고사
-Codeimport java.util.Arrays;import java.util.stream.IntStream;class Solution { public int[] solution(int[] answers) { int[] cnt = {0, 0, 0}; int[][] person = { {1, 2, 3, 4, 5}, {2, 1, 2, 3, 2, 4, 2, 5}, {3, 3, 1, 1, 2, 2, 4, 4, 5, 5} }; for (int i = 0; i cnt[i] == max) .map(i -> i + 1).toArray(); }}
2025. 2. 26.
[프로그래머스/Java] 2016년
-Codeimport java.util.Arrays;class Solution { public String solution(int a, int b) { String[] days = {"THU", "FRI","SAT", "SUN","MON","TUE","WED"}; int[] month = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int total = Arrays.stream(month, 0, a - 1).sum() + b; return days[total % 7]; }}
2025. 2. 26.
[프로그래머스/Java] 기사단원의 무기
-Codeclass Solution { public int solution(int number, int limit, int power) { int answer = 0; int cnt; for (int i = 1; i 처음에는 1, n까지 모두 검사를 했으나 시간 초과로 틀렸습니다. 그래서 공식을 찾아보니 제곱근을 이용하는 방법을 찾게되었고 다음과 같습니다.1~n까지를 검사할때 예를 들어 n이 24면 1, 2, 3, 4, 6, 8, 12, 24인데 각각 1 * 24, 2 * 12, 3 * 8, 4 * 6으로 묶어서 값을 2개씩 찾는게 가능합니다. 하지만, n이 16처럼 1, 2, 4, 8, 16과 같은 경우 1 * 16, 2 * 8, 4 * 4로 되어서 같은 값..
2025. 2. 26.