Skip to content

Commit fad9b25

Browse files
fix indent
1 parent a99c988 commit fad9b25

File tree

2 files changed

+54
-54
lines changed

2 files changed

+54
-54
lines changed

course-schedule/dev-jonghoonpark.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33

44
```java
55
public class Solution {
6-
public boolean canFinish(int numCourses, int[][] prerequisites) {
6+
public boolean canFinish(int numCourses, int[][] prerequisites) {
77
if (prerequisites.length == 0) {
88
return true;
99
}
1010

11-
Map<Integer, Node> vertexMap = new HashMap<>();
11+
Map<Integer, Node> vertexMap = new HashMap<>();
1212

1313
for (int[] prerequisite : prerequisites) {
1414
vertexMap.putIfAbsent(prerequisite[0], new Node(prerequisite[0]));
@@ -23,7 +23,7 @@ public class Solution {
2323

2424
Deque<Integer> deque = new LinkedList<>();
2525

26-
int[] degrees = new int[numCourses];
26+
int[] degrees = new int[numCourses];
2727
for (int i = 0; i < degrees.length; i++) {
2828
Node vertex = vertexMap.get(i);
2929
if (vertex != null) {
@@ -47,18 +47,18 @@ public class Solution {
4747
}
4848

4949
return vertexMap.isEmpty();
50-
}
50+
}
5151
}
5252

5353
class Node {
54-
int id;
55-
List<Node> edges;
54+
int id;
55+
List<Node> edges;
5656
List<Node> reversedEdges;
5757

58-
public Node(int id) {
59-
this.id = id;
60-
edges = new ArrayList<>();
58+
public Node(int id) {
59+
this.id = id;
60+
edges = new ArrayList<>();
6161
reversedEdges = new ArrayList<>();
62-
}
62+
}
6363
}
6464
```

pacific-atlantic-water-flow/dev-jonghoonpark.md

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -3,53 +3,53 @@
33

44
```java
55
public class Solution {
6-
public List<List<Integer>> pacificAtlantic(int[][] heights) {
7-
List<List<Integer>> result = new ArrayList<>();
8-
9-
for (int i = 0; i < heights.length; i++) {
10-
for (int j = 0; j < heights[0].length; j++) {
11-
System.out.printf("\n\ninit Flow : %d, %d\n", i, j);
12-
Flow flow = new Flow();
13-
dfs(flow, heights, Integer.MAX_VALUE, i, j);
14-
if (flow.flowToAtlanticOcean && flow.flowToPacificOcean) {
15-
result.add(List.of(i, j));
16-
}
17-
}
18-
}
19-
20-
return result;
21-
}
22-
23-
private void dfs(Flow flow, int[][] heights, int prev, int i, int j) {
24-
if (i == -1 || j == -1) {
25-
flow.flowToPacificOcean = true;
26-
return;
27-
}
28-
29-
if (i == heights.length || j == heights[0].length) {
30-
flow.flowToAtlanticOcean = true;
31-
return;
32-
}
33-
34-
if (heights[i][j] == -1 || heights[i][j] > prev || flow.flowToAtlanticOcean && flow.flowToPacificOcean) {
35-
return;
36-
}
37-
38-
int currentHeight = heights[i][j];
39-
heights[i][j] = -1;
40-
41-
dfs(flow, heights, currentHeight, i + 1, j);
42-
dfs(flow, heights, currentHeight, i - 1, j);
43-
dfs(flow, heights, currentHeight, i, j + 1);
44-
dfs(flow, heights, currentHeight, i, j - 1);
45-
46-
heights[i][j] = currentHeight;
47-
}
6+
public List<List<Integer>> pacificAtlantic(int[][] heights) {
7+
List<List<Integer>> result = new ArrayList<>();
8+
9+
for (int i = 0; i < heights.length; i++) {
10+
for (int j = 0; j < heights[0].length; j++) {
11+
System.out.printf("\n\ninit Flow : %d, %d\n", i, j);
12+
Flow flow = new Flow();
13+
dfs(flow, heights, Integer.MAX_VALUE, i, j);
14+
if (flow.flowToAtlanticOcean && flow.flowToPacificOcean) {
15+
result.add(List.of(i, j));
16+
}
17+
}
18+
}
19+
20+
return result;
21+
}
22+
23+
private void dfs(Flow flow, int[][] heights, int prev, int i, int j) {
24+
if (i == -1 || j == -1) {
25+
flow.flowToPacificOcean = true;
26+
return;
27+
}
28+
29+
if (i == heights.length || j == heights[0].length) {
30+
flow.flowToAtlanticOcean = true;
31+
return;
32+
}
33+
34+
if (heights[i][j] == -1 || heights[i][j] > prev || flow.flowToAtlanticOcean && flow.flowToPacificOcean) {
35+
return;
36+
}
37+
38+
int currentHeight = heights[i][j];
39+
heights[i][j] = -1;
40+
41+
dfs(flow, heights, currentHeight, i + 1, j);
42+
dfs(flow, heights, currentHeight, i - 1, j);
43+
dfs(flow, heights, currentHeight, i, j + 1);
44+
dfs(flow, heights, currentHeight, i, j - 1);
45+
46+
heights[i][j] = currentHeight;
47+
}
4848
}
4949

5050
class Flow {
51-
boolean flowToPacificOcean;
52-
boolean flowToAtlanticOcean;
51+
boolean flowToPacificOcean;
52+
boolean flowToAtlanticOcean;
5353
}
5454
```
5555

0 commit comments

Comments
 (0)