목록프로그래머스/프로그래머스 LV.1 (10)
밍쎄의 코딩공간
import java.util.HashMap; class Solution { public int[] solution(String[] keymap, String[] targets) { HashMap hm = new HashMap(); int[] ret = new int[targets.length]; for(String key : keymap) { for(int i=0 ; i
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/cd7Cm1/btsrTOmlMJ3/kK4DSQhiGpaD1bcB5EajKK/img.png)
1. 문자열의 모든 문자에 대해 반복 A. 문자가 공백 문자일 경우 - 그대로 이어 붙이기 - 다음 등장하는 알파벳은 대문자 B. 공백 문자가 아닌 경우 - 대, 소문자 변환하여 이어 붙이기 - 다음 등장하는 알파벳의 대, 소문자는 현재 변환하는 문자와 반대 class Solution { public String solution(String s) { StringBuilder builder = new StringBuilder(); boolean toUpper = true; for (char c : s.toCharArray()){ if(!Character.isAlphabetic(c)){ builder.append(c); toUpper = true; }else{ if(toUpper){ builder.appen..
그래프 탐색 문제이다. 푸는 과정 속에 어려움을 겪어 밑에 분의 코드를 참고하였다. // 2차원 배열을 벗어나지 않으면서 X가 아니면 재귀 호출 이 부분을 구현하는 것이 매우 미흡하였다. import java.util.*; class Solution { static int startX; static int startY; public int[] solution(String[] park, String[] routes) { int[] answer = new int[2]; // 동서남북 이동할 좌표 map에 삽입 Map map = new HashMap(); map.put("N", new int[]{-1, 0}); map.put("E", new int[]{0, 1}); map.put("S", new int[]{1..
class Solution { public int solution(int n, int m, int[] section) { int answer = 0; int min = 0; for(int num : section){ if(answer == 0){ min = num; answer++; } if(min + m
import java.util.HashMap; class Solution { public String solution(String[] participant, String[] completion) { String answer =""; HashMap hm = new HashMap(); for(String player : participant) hm.put(player, hm.getOrDefault(player, 0) + 1); for(String player : completion) hm.put(player, hm.get(player) -1); for(String key : hm.keySet()) { if(hm.get(key) != 0) { answer = key; System.out.println(answ..
오늘의 문제는 자꾸 오류가 났다. 1번방법 import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; class Solution { public int[] solution(String[] idList, String[] report, int k){ // @param idList : 이용자의 ID를 담은 배열. // @param report : 신고한 이용자와 신고당한 이용자의 정보를 담은 배열. ex) "a b",.. -> a가 b를 신고 // @param k : 신고 횟수에 따른 정지 기준 정수값. // @return answer : id_list에 담긴 id 순서대로 각 유저가 받은 신고 결과 메일 개수 배열. int[] a..