From 353bad2ada7628dccd461234c0cbc409384ef0a0 Mon Sep 17 00:00:00 2001 From: 724thomas <724thomas@gmail.com> Date: Mon, 19 May 2025 10:21:47 +0900 Subject: [PATCH 1/2] =?UTF-8?q?[=EC=B5=9C=EC=9B=90=EC=A4=80]Day16?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Q117.java" | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 "leetcode2/2medium/\354\265\234\354\233\220\354\244\200/Q117.java" diff --git "a/leetcode2/2medium/\354\265\234\354\233\220\354\244\200/Q117.java" "b/leetcode2/2medium/\354\265\234\354\233\220\354\244\200/Q117.java" new file mode 100644 index 00000000..a98fdc75 --- /dev/null +++ "b/leetcode2/2medium/\354\265\234\354\233\220\354\244\200/Q117.java" @@ -0,0 +1,56 @@ +package Leetcode.최원준; + +/* +1. 아이디어 : + + +2. 시간복잡도 : +O( ) + +3. 자료구조/알고리즘 : + + */ + +public class Q117 { +/* +// Definition for a Node. +class Node { + public int val; + public Node left; + public Node right; + public Node next; + + public Node() {} + + public Node(int _val) { + val = _val; + } + + public Node(int _val, Node _left, Node _right, Node _next) { + val = _val; + left = _left; + right = _right; + next = _next; + } +}; + + + class Solution { + Map depthsMap = new HashMap<>(); + public void postOrder(Node node, int depths) { + if (node == null) return; + + postOrder(node.right, depths+1); + postOrder(node.left, depths+1); + + node.next = depthsMap.getOrDefault(depths, null); + depthsMap.put(depths, node); + } + + public Node connect(Node root) { + postOrder(root, 0); + return root; + } + } + */ +} From 39b8adc56f255b39db630c4404d8d62f6f97cbb7 Mon Sep 17 00:00:00 2001 From: 724thomas <724thomas@gmail.com> Date: Mon, 19 May 2025 10:21:48 +0900 Subject: [PATCH 2/2] =?UTF-8?q?[=EC=B5=9C=EC=9B=90=EC=A4=80]Day16?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Q892.java" | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 "leetcode2/1easy/\354\265\234\354\233\220\354\244\200/Q892.java" diff --git "a/leetcode2/1easy/\354\265\234\354\233\220\354\244\200/Q892.java" "b/leetcode2/1easy/\354\265\234\354\233\220\354\244\200/Q892.java" new file mode 100644 index 00000000..84acf531 --- /dev/null +++ "b/leetcode2/1easy/\354\265\234\354\233\220\354\244\200/Q892.java" @@ -0,0 +1,43 @@ +package Leetcode.최원준; + +/* +1. 아이디어 : + + +2. 시간복잡도 : +O( ) + +3. 자료구조/알고리즘 : + + */ + +public class Q892 { + class Solution { + int[] dx = {0,0,1,-1}, dy = {1,-1,0,0}; + int n,m ; + int[][] grid; + public int countArea(int row, int col) { + int height = grid[row][col]; + int area = (height == 0) ? 0 : 2; //bottom, top + + for (int i=0; i<4; i++) { + int nx = row + dx[i], ny = col + dy[i]; + int neighbor = (nx<0 || ny<0 || nx>=n || ny>=m) ? 0 : grid[nx][ny]; + area += Math.max(0, height - neighbor); + } + return area; + } + + public int surfaceArea(int[][] grid) { + n = grid.length; + m = grid[0].length; + this.grid = grid; + + int ans = 0; + for (int i=0; i