Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions leetcode2/1easy/최원준/Q892.java
Original file line number Diff line number Diff line change
@@ -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<n; i++) for (int j=0; j<m; j++) {
ans += countArea(i,j);
}
return ans;
}
}
}
56 changes: 56 additions & 0 deletions leetcode2/2medium/최원준/Q117.java
Original file line number Diff line number Diff line change
@@ -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<Integer, Node> 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;
}
}
*/
}