본문 바로가기

문제풀이64

프로그래머스 완주하지 못한 선수 Java import java.util.*; class Solution { public String solution(String[] participant, String[] completion) { String answer = ""; Map map = new HashMap(); for(String item : participant) { map.computeIfPresent(item,(String key, Integer value)->++value); map.putIfAbsent(item,1); } for(String comple : completion) { map.computeIfPresent(comple,(String key, Integer value)->--value); } for(int i=0;i 2021. 3. 31.
프로그래머스 체육복 Java class Solution { public int solution(int n, int[] lost, int[] reserve) { int answer = 0; int[] student = new int[n]; for (int i = 0; i < n; i++) { student[i]++; } for (int steal : lost) { student[steal-1]--; } for (int giving : reserve) { student[giving-1]++; } for (int i = 0; i < n; i++) { if (student[i] == 2) { if (i != 0 && student[i - 1] == 0) { student[i]--; student[i - 1]++; } else if (i !.. 2021. 3. 31.
프로그래머스 H-Index Java //문제가 이해가 잘 안되긴 했는데.. 어찌어찌 잘 풀었습니다.. import java.util.*; class Solution { public int solution(int[] citations) { int answer = 0; Integer[] arr = new Integer[citations.length]; for (int i = 0; i < arr.length; i++) { arr[i] = citations[i]; } Arrays.sort(arr,Collections.reverseOrder()); for (int i = 0; i < arr.length; i++) { if (i 2021. 3. 31.
프로그래머스 가장 큰 수 JAVA import java.util.*; class Solution { public void intToString(int[] numbers, String[] stringNumbers) { for (int i = 0; i { String temp1 = o1+o2; String temp2 = o2+o1; if(Integer.parseInt(temp1) > Integer.parseInt(temp2)) { retu.. 2021. 3. 27.