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
31 changes: 31 additions & 0 deletions leetcode2/1easy/염류선/Q2956.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package Leetcode.염류선;


class Solution {
public int[] findIntersectionValues(int[] nums1, int[] nums2) {
int[] answer = new int[2];
int same = 0;
int min = Math.min(nums1.length, nums2.length);
for (int i = 0; i < nums1.length; i ++) {
for (int j = 0; j < nums2.length; j ++) {
if (nums1[i] == nums2[j]) {
same++;
break;
}
}
}
answer[0] = same;

same = 0;
for (int i = 0; i < nums2.length; i ++) {
for (int j = 0; j < nums1.length; j ++) {
if (nums2[i] == nums1[j]) {
same++;
break;
}
}
}
answer[1] = same;
return answer;
}
}
40 changes: 40 additions & 0 deletions leetcode2/2medium/염류선/Q3531.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package Leetcode.염류선;

public class Q3531 {
static boolean[][] graph;
static int[] dx = {1, 0, -1, 0};
static int[] dy = {0, -1, 0, 1};

public int countCoveredBuildings(int n, int[][] buildings) {
int answer = 0;
graph = new boolean[n + 2][n + 2];

for (int[] xy : buildings) {
int x = xy[0];
int y = xy[1];
graph[x][y] = true;
}

for (int[] xy : buildings) {
int x = xy[0];
int y = xy[1];

boolean isCovered = true;
for (int i = 0; i < 4; i++) {
int nx = x + dx[i];
int ny = y + dy[i];

if (!graph[nx][ny]) {
isCovered = false;
break;
}
}

if (isCovered) {
answer++;
}
}

return answer;
}
}