알고리즘 풀이

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354import java.util.*; class Solution { public int[] solution(String[] id_list, String[] report, int k) { Map userMap = new HashMap(); for(String id : id_list) userMap.put(id, new User(id)); // System.out.println(userMap.size()); List bannedIdList = new ArrayList(); for(String r : report){ String[] st..
12345678910111213141516class Solution { public String[] solution(int n, int[] arr1, int[] arr2) { String[] answer = new String[n]; for(int i=0; i
123456789101112131415161718import java.util.*; class Solution { public String[] solution(String[] strings, int n) { ArrayList arr = new ArrayList(); for (int i = 0; i
12345678910111213141516171819202122class Solution { public String solution(String s, int n) { char[] chArr = s.toCharArray(); for(int i=0; i
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677import java.util.*; class Solution { List nodeList; int nodeNum; int answer; boolean[] visited; class Node{ int num; List edge; Node(int num){ this.num = num; edge = new ArrayList(); } } public int solution(int n, int[][] wires) { nodeList = new ArrayLi..
1234567891011121314151617181920import java.util.*; class Solution { public int solution(int[][] sizes) { int a = 0; int b = 0; for(int[] size : sizes){ int lg = Math.max(size[0],size[1]); int sm = Math.min(size[0],size[1]); a = Math.max(a,lg); b = Math.max(b,sm); } return a*b; }} Colored by Color Scriptercs
#2 메모리↓↓ 참고 : https://bangu4.tistory.com/241 참고 안보고는 이런 방식으로 못품 공백을 포함하기 때문에 unit[i] = unit[i+1]*5 +1이라는 공식을 도출을 못낼 것 같음... 1 2 3 4 5 6 7 8 9 10 11 12 13 14 class Solution { public int solution(String word) { int answer = word.length(); // char[] alp = new char[]{'A','E','I','O','U'}; String alp = "AEIOU"; int[] unit = new int[]{781,156,31,6,1}; for(int i=0; i
처음에는 백트래킹으로 하려고 했는데 순열을 전부 짜 놓은 다음에 해결하는 것이 훨씬 간편하기도 하고 백트래킹으로 불가능한지 아닌지는 잘 모르겠으나 조건상 어려워 보였음 순열 짜기 -> 짠 순열이 문제에서 주어진 Data(조건)을 전부 만족시키면 answer++(count) 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 79 80 81 import java..
어렵게 생각한 부분이 있는데.. 문제에서 주어진 예제에서 0(0)인 경우에 0이 나오는 것을 보고 (0)이 나오면 앞에 K(Q)형태에서 K값이 어떤 값이든 0이 나오는 것으로 착각했다.. 이것 때문에 경우의 수 엄청 늘어나는 것 같아서 index를 i=1부터 시작하고 i
12345678910111213141516171819202122232425262728class Solution { public int solution(int[] a) { int len = a.length; if(a.length
배게
'알고리즘 풀이' 카테고리의 글 목록 (5 Page)