File tree Expand file tree Collapse file tree 1 file changed +51
-1
lines changed
LeetCodeNet/G0401_0500/S0427_construct_quad_tree Expand file tree Collapse file tree 1 file changed +51
-1
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,57 @@ namespace LeetCodeNet.G0401_0500.S0427_construct_quad_tree {
3
3
// #Medium #Array #Tree #Matrix #Divide_and_Conquer #Top_Interview_150_Divide_and_Conquer
4
4
// #2025_07_18_Time_91_ms_(66.88%)_Space_47.25_MB_(80.00%)
5
5
6
- using LeetCodeNet . Com_github_leetcode ;
6
+ using System . Text ;
7
+
8
+ public class Node {
9
+ public bool val ;
10
+ public bool isLeaf ;
11
+ public Node ? topLeft ;
12
+ public Node ? topRight ;
13
+ public Node ? bottomLeft ;
14
+ public Node ? bottomRight ;
15
+
16
+ public Node ( bool val , bool isLeaf ) {
17
+ this . val = val ;
18
+ this . isLeaf = isLeaf ;
19
+ this . topLeft = null ;
20
+ this . topRight = null ;
21
+ this . bottomLeft = null ;
22
+ this . bottomRight = null ;
23
+ }
24
+
25
+ public Node (
26
+ bool val ,
27
+ bool isLeaf ,
28
+ Node ? topLeft ,
29
+ Node ? topRight ,
30
+ Node ? bottomLeft ,
31
+ Node ? bottomRight ) {
32
+ this . val = val ;
33
+ this . isLeaf = isLeaf ;
34
+ this . topLeft = topLeft ;
35
+ this . topRight = topRight ;
36
+ this . bottomLeft = bottomLeft ;
37
+ this . bottomRight = bottomRight ;
38
+ }
39
+
40
+ public override string ToString ( ) {
41
+ StringBuilder sb = new StringBuilder ( ) ;
42
+ sb . Append ( GetNodeString ( this ) ) ;
43
+ sb . Append ( GetNodeString ( topLeft ) ) ;
44
+ sb . Append ( GetNodeString ( topRight ) ) ;
45
+ sb . Append ( GetNodeString ( bottomLeft ) ) ;
46
+ sb . Append ( GetNodeString ( bottomRight ) ) ;
47
+ return sb . ToString ( ) ;
48
+ }
49
+
50
+ private string GetNodeString ( Node ? node ) {
51
+ if ( node == null ) {
52
+ return "[]" ;
53
+ }
54
+ return $ "[{ ( node . isLeaf ? "1" : "0" ) } ,{ ( node . val ? "1" : "0" ) } ]";
55
+ }
56
+ }
7
57
8
58
/*
9
59
// Definition for a QuadTree node.
You can’t perform that action at this time.
0 commit comments