목록전체 글 (166)
공부기록
문제 https://programmers.co.kr/learn/courses/30/lessons/12907 코드 import java.util.*; class Solution { // static int answer = 0; // int dp[][] = new int[100001][100]; // void dfs(int[] money, int left, int threshold){ // if(left == 0){ // answer = (answer+1)%1000000007; // return; // }else{ // if(threshold = money[threshold]) // dfs(money, left-money[threshold], threshold); ..
문제 https://programmers.co.kr/learn/courses/30/lessons/12938# 코드 class Solution { public int[] solution(int n, int s) { int[] answer = {}; int num = s/n; if(num == 0) return new int[]{-1}; int left = s%n; answer = new int[n]; for(int i=0; i
문제 https://programmers.co.kr/learn/courses/30/lessons/49191 코드 import java.util.*; class Solution { int bfs(ArrayList g[], int s_idx){ Queue q = new LinkedList(); boolean visit[] = new boolean[g.length]; int count = 0; q.add(s_idx); visit[s_idx] = true; while(!q.isEmpty()){ count++; int cur_idx = q.poll(); for(int next_idx : g[cur_idx]){ if(visit[next_idx] == false){ q.add(next_idx); visit[next_..
문제 https://programmers.co.kr/learn/courses/30/lessons/43238# 코드 import java.util.*; class Solution { private int is_prom(int n, long mid, int[] times){ long left_man = n; for(int time : times){ left_man -= (mid/time); } // System.out.println("n : " + n + ", left_man : " + left_man); if(left_man > 0) return -1; else return 0; } public long solution(int n, int[] times) { long answer = 0; long low ..
문제 https://programmers.co.kr/learn/courses/30/lessons/42884 코드 import java.util.*; class Solution { class Node implements Comparable{ int s; int e; public Node(int s, int e){ this.s = s; this.e = e; } public int compareTo(Node obj){ if(this.s obj.s) return 1; else return 0; } } public int solution(int[][] routes) { int answer = 0; PriorityQueue pq = new Prior..
문제 https://programmers.co.kr/learn/courses/30/lessons/42861 코드 import java.util.*; class Solution{ class Node implements Comparable{ int e; int w; public Node(int e, int w){ this.e = e; this.w = w; } @Override public int compareTo(Node obj){ if(this.w > obj.w) return 1; else if(this.w < obj.w) return -1; else return 0; } } public int solution(int n, int[][] costs) { int answer = 0; ArrayList g[]..
문제 https://programmers.co.kr/learn/courses/30/lessons/43164# 코드 import java.util.*; class Solution { void dfs(String[][] tickets, HashMap map, HashMap tckt_count, ArrayList res, ArrayList cur_arr, String cur_pos, int count){ if(count == tickets.length){ ArrayList res_arr = new ArrayList(); for(int i=0; i
문제 https://programmers.co.kr/learn/courses/30/lessons/42628# 코드 import java.util.*; class Solution { public int[] solution(String[] operations) { int[] answer = {0, 0}; PriorityQueue rpq = new PriorityQueue(); PriorityQueue pq = new PriorityQueue(Collections.reverseOrder()); for(String oper : operations){ String[] oper_arr = oper.split(" "); String cmd = oper_arr[0]; int arg = Integer.valueOf(op..