알고리즘 풀이/프로그래머스

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485import java.util.*; class Solution { class Node{ boolean removed; Node prev; Node next; } Node[] NodeArr = new Node[1000000]; public String solution(int n, int k, String[] cmd) { for(int i=0; i
BFS가 정석인데 완전탐색으로 가라쳐서 했음 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 import java.util.*; class Solution { public int[] solution(String[][] places) { List list = new ArrayList(); Loop1 : for(String[] place : places){ char[][] waitArr = new char[10][10]; for(int i=2; i
12345678910111213141516171819202122232425262728293031323334import java.util.*; class Solution { public int solution(String s) { Map map = new HashMap(); map.put("zero", 0); map.put("one", 1); map.put("two", 2); map.put("three", 3); map.put("four", 4); map.put("five", 5); map.put("six", 6); map.put("seven", 7); map.put("eight", 8); map.put("nine", 9); System.out.println(s); for(Map.Entry entry : ..
다시 풀었는데 테캐 1개틀림 [인덱스 부분 실수한거임.. 인덱스가 ㅈㄴ 중요함 진짜 실수 많이함 이부분에서] -> start end 한칸씩 이동해주는 것을 투포인터 알고리즘이라고 하나봄 가장 중요한 점은.. adv_time을 1칸씩 옮기는 개념인데.. 나같은 경우는 당연히 0부터 시작해서 adv_time에 해당하는 index가 가진 값 박아주고 또 1부터 시작해서 index+1까지 박아주고 멍청하게 했음.. [앞에 인덱스의 값 1개 지우고 뒤에 인덱스의 값 1개 추가하면됨] 출처 : https://www.youtube.com/watch?v=Xx5bk_EP8tQ 해설에는 완전 탐색, 브루트 포스인데 케이스 2개가 틀림 1개는 시간 초과, 하나는 그냥 틀린 것 알고보니 나는 무식하게 광고시간을 한칸씩 옮겼는..
index부분 이상하게 넣어서 삽질 너무 많이 함 index는 처음 코딩할 때 2번씩 검사해도 안 부족할듯 ++ floyd 알고리즘 부분 3중 for문에서 k, i, j 순으로 해줘야함, i, j, k로 했다가 40/100나왔음 경로를 한다는 개념은 알겠는데 3중 for문의 가장 첫번째 for문이 경로 지점을 고정시켜주는 것임을 명확하게 이해를 못한 것 같다 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 import java.util.*; class Solut..
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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 import java.util.*; class Solution { Map Wordmap = new HashMap(); List ScoreList = new ArrayList(); public int[] solution(String[] info, String[] query) { Wordmap.put("-", 0..
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 63 64 65 66 import java.util.*; class Solution { List Foodmaps = new ArrayList(); int[] MaxCnt = new int[11]; void comb(char[] arr, int pos, StringBuilder sBuilder){ if(pos>= arr.length){ if(sBuilder.length()>=2){ int len..
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172class Solution { public static String solution(String new_id) { String answer = new KAKAOID(new_id) .replaceToLowerCase() .filter() .toSingleDot() .deleteStartEndDot() .noBlank() .noGreaterThan16() .noLessThan2() .getResult(); return answer; } private static clas..
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 public int solution(int[][] baseball) { int answer = 0; boolean[] used = new boolean[10]; int strike, ball, rightConditionNum; for(int hun=1; hun
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 static final int STUDENT_NUM = 3; static int[] student1_guessPattern = {1,2,3,4,5}; static int[] student2_guessPattern = {2,1,2,3,2,4,2,5}; static int[] student3_guessPattern = {3,3,1,1,2,2,4,4,5,5}; public int[] solution(int[] answers) { int[] score = getScore(answers); int topScore = getTopScore(s..
배게
'알고리즘 풀이/프로그래머스' 카테고리의 글 목록 (6 Page)