본문 바로가기

전체 글206

[Java] 프로그래머스 [Level-2] 디펜스 게임 import java.util.PriorityQueue; public class Solution { // 디펜스 게임 public static int solution(int n, int k, int[] enemy) { int answer = enemy.length; // 모든 라운드 클리어 가능할 경우의 리턴 값 PriorityQueue pq = new PriorityQueue(); // 무적권을 사용해 해치울 적의 수를 남기기 위한 우선순위 큐 // 디펜스 게임 시작 for(int i = 0; i < enemy.length; i++) { // 4, 2, 4, 5, 3, 3, 1 pq.offer(enemy[i]); // 4 // 2, 4 // 2, 4, 4 // 2, 4, 4, 5 // 3, 4, 4, .. 2022. 12. 27.
[Java] 백준 [11048] 이동하기 public class Solution { // 이동하기 - DP 11048번 static int n = 3; static int m = 4; static int[][] arr = {{1, 2, 3, 4}, {0, 0, 0, 5}, {9, 8, 7, 6}}; static int[] dy = {1, 1, 0}; static int[] dx = {0, 1, 1}; static int[][] dp = new int[n][m]; public static void dfs(int a, int b) { for(int i = 0; i n - 1 || nx > m - 1) { continue; } // dp 갱신 .. 2022. 12. 26.
[SQL] 프로그래머스 [Level-4] 저자 별 카테고리 별 매출액 집계하기 SELECT A.AUTHOR_ID , B.AUTHOR_NAME , A.CATEGORY , SUM(A.PRICE * C.SALES) AS TOTAL_SALES FROM BOOK A , AUTHOR B , BOOK_SALES C WHERE A.AUTHOR_ID = B.AUTHOR_ID AND A.BOOK_ID = C.BOOK_ID AND DATE_FORMAT(C.SALES_DATE, '%Y-%m') = '2022-01' GROUP BY A.AUTHOR_ID, A.CATEGORY, B.AUTHOR_NAME ORDER BY A.AUTHOR_ID, A.CATEGORY DESC SELECT A.AUTHOR_ID , B.AUTHOR_NAME , A.CATEGORY , SUM(A.PRICE * C.SALES) AS T.. 2022. 12. 25.
[Java] 백준 [2178] 미로 탐색 import java.util.LinkedList; import java.util.Queue; public class Solution { // 미로 탐색 - BFS 2178번 // 최단 거리 탐색 BFS static int r = 4; static int c = 6; static int[][] arr = {{1, 0, 1, 1, 1, 1}, {1, 0, 1, 0, 1, 0}, {1, 0, 1, 0, 1, 1}, {1, 1, 1, 0, 1, 1}}; static boolean[][] visit = {}; static int[] dx = {0, 0, -1, 1}; static int[] dy = {-1, 1, 0, 0}; public static void bfs(int n, int m) { Queue q =.. 2022. 12. 24.
[Block Chain] Java 실습-3 core > BlockChainStarter package core; import java.util.ArrayList; public class BlockChainStarter { public static void main(String[] args) { // TODO Auto-generated method stub Block block1 = new Block(1, null, 0, new ArrayList()); block1.mine(); block1.getInformation(); Block block2 = new Block(2, block1.getBlockHash(), 0, new ArrayList()); block2.addTransaction(new Transaction("이승엽", "홍길동", 1.5.. 2022. 12. 21.
[Block Chain] Java 실습-2 core > BlockChainStarter package core; public class BlockChainStarter { public static void main(String[] args) { // TODO Auto-generated method stub Block block1 = new Block(1, null, 0, "데이터"); // 블록 아이디, 이전 블록의 해시 값, 채굴을 위한 정답, 블록에 들어가는 데이터 block1.mine(); block1.getInformation(); Block block2 = new Block(2, block1.getBlockHash(), 0, "데이터"); block2.mine(); block2.getInformation(); Block block3 = .. 2022. 12. 21.