본문 바로가기

Problem Solving37

[프로그래머스] L2 튜플 / 2019 카카오 겨울 인턴십 (Java) [프로그래머스] L2 캐시 / 2019 카카오 겨울 인턴십 [풀이] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 import java.util.*; class Solution { public int[] solution(String s) { s = s.substring(2, s.length()-2).replace("},{","-"); String[] arr = s.split("-"); if(arr.length==1) return new int[] {Integer.parseInt(arr[0])}; Arrays.sort(arr, new Comparator() { @Override public int com.. 2020. 12. 19.
[프로그래머스] L2 후보키 / 2019 카카오 블라인드 채용 (Java) [프로그래머스] L2 캐시 / 2019 카카오 블라인드 채용 [풀이] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 import java.util.*; class Solution { static Set visit = new HashSet(); // 후보키 static List list = new ArrayList(); // 조합 static int answer = 0, size; public int solution(String[][] re.. 2020. 12. 19.
[프로그래머스] L2 소수 만들기 [프로그래머스] L2 소수 만들기 [풀이] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 class Solution { static int answer = 0; static boolean[] primeN= new boolean[3001]; static boolean[] chk = new boolean[3001]; public int solution(int[] nums) { solve(0,0,0,nums); return answer; } static void solve(int idx, int sum, int cnt, int[] nums){ for(int i=0; i 2020. 12. 15.
[프로그래머스] L2 영어 끝말잇기 [프로그래머스] L2 영어 끝말잇기 [풀이] 두 가지 조건에 유의하여 구현한다. 1. 앞 단어의 마지막 글자와 뒷 단어의 첫 글자가 같은지 여부(구현) 2. 이전에 나온 단어인지(HashSet 사용) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 import java.util.*; class Solution { public int[] solution(int n, String[] words) { int[] answer = new int[] {0,0}; Set set = new HashSet(); set.add(words[0]); for(int i=1; i 2020. 12. 15.