Skip to content

Commit 9a9c0f5

Browse files
authored
Improve task 427.
1 parent 256c5a6 commit 9a9c0f5

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

src/main/java/g0401_0500/s0427_construct_quad_tree/Solution.java

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,44 @@
33
// #Medium #Array #Tree #Matrix #Divide_and_Conquer
44
// #2022_03_18_Time_1_ms_(85.16%)_Space_46.3_MB_(67.10%)
55

6+
/*
7+
// Definition for a QuadTree node.
8+
class Node {
9+
public boolean val;
10+
public boolean isLeaf;
11+
public Node topLeft;
12+
public Node topRight;
13+
public Node bottomLeft;
14+
public Node bottomRight;
15+
16+
public Node() {
17+
this.val = false;
18+
this.isLeaf = false;
19+
this.topLeft = null;
20+
this.topRight = null;
21+
this.bottomLeft = null;
22+
this.bottomRight = null;
23+
}
24+
25+
public Node(boolean val, boolean isLeaf) {
26+
this.val = val;
27+
this.isLeaf = isLeaf;
28+
this.topLeft = null;
29+
this.topRight = null;
30+
this.bottomLeft = null;
31+
this.bottomRight = null;
32+
}
33+
34+
public Node(boolean val, boolean isLeaf, Node topLeft, Node topRight, Node bottomLeft, Node bottomRight) {
35+
this.val = val;
36+
this.isLeaf = isLeaf;
37+
this.topLeft = topLeft;
38+
this.topRight = topRight;
39+
this.bottomLeft = bottomLeft;
40+
this.bottomRight = bottomRight;
41+
}
42+
};
43+
*/
644
public class Solution {
745
public Node construct(int[][] grid) {
846
return optimizedDfs(grid, 0, 0, grid.length);
@@ -30,7 +68,6 @@ private Node optimizedDfs(int[][] grid, int rowStart, int colStart, int len) {
3068
break;
3169
}
3270
}
33-
3471
if (oneCount > 0 && zeroCount > 0) {
3572
int midLen = len / 2;
3673
Node topLeft = optimizedDfs(grid, rowStart, colStart, midLen);

0 commit comments

Comments
 (0)