File tree 11 files changed +18
-18
lines changed
lcof2/剑指 Offer II 043. 往完全二叉树添加节点
solution/0900-0999/0919.Complete Binary Tree Inserter
11 files changed +18
-18
lines changed Original file line number Diff line number Diff line change @@ -301,7 +301,7 @@ class CBTInserter {
301
301
return ;
302
302
}
303
303
const q: TreeNode [] = [root ];
304
- while (q .length > 0 ) {
304
+ while (q .length ) {
305
305
const t: TreeNode [] = [];
306
306
for (const node of q ) {
307
307
this .tree .push (node );
@@ -355,7 +355,7 @@ var CBTInserter = function (root) {
355
355
return ;
356
356
}
357
357
const q = [root];
358
- while (q .length > 0 ) {
358
+ while (q .length ) {
359
359
const t = [];
360
360
for (const node of q) {
361
361
this .tree .push (node);
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ class CBTInserter {
27
27
}
28
28
}
29
29
}
30
-
30
+
31
31
int insert (int val) {
32
32
auto p = tree[(tree.size () - 1 ) / 2 ];
33
33
auto node = new TreeNode (val);
@@ -39,7 +39,7 @@ class CBTInserter {
39
39
}
40
40
return p->val ;
41
41
}
42
-
42
+
43
43
TreeNode* get_root () {
44
44
return tree[0 ];
45
45
}
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ public CBTInserter(TreeNode root) {
32
32
}
33
33
}
34
34
}
35
-
35
+
36
36
public int insert (int val ) {
37
37
TreeNode p = tree .get ((tree .size () - 1 ) / 2 );
38
38
TreeNode node = new TreeNode (val );
@@ -44,7 +44,7 @@ public int insert(int val) {
44
44
}
45
45
return p .val ;
46
46
}
47
-
47
+
48
48
public TreeNode get_root () {
49
49
return tree .get (0 );
50
50
}
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ var CBTInserter = function (root) {
15
15
return ;
16
16
}
17
17
const q = [ root ] ;
18
- while ( q . length > 0 ) {
18
+ while ( q . length ) {
19
19
const t = [ ] ;
20
20
for ( const node of q ) {
21
21
this . tree . push ( node ) ;
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ class CBTInserter {
20
20
return ;
21
21
}
22
22
const q : TreeNode [ ] = [ root ] ;
23
- while ( q . length > 0 ) {
23
+ while ( q . length ) {
24
24
const t : TreeNode [ ] = [ ] ;
25
25
for ( const node of q ) {
26
26
this . tree . push ( node ) ;
Original file line number Diff line number Diff line change @@ -308,7 +308,7 @@ class CBTInserter {
308
308
return ;
309
309
}
310
310
const q: TreeNode [] = [root ];
311
- while (q .length > 0 ) {
311
+ while (q .length ) {
312
312
const t: TreeNode [] = [];
313
313
for (const node of q ) {
314
314
this .tree .push (node );
@@ -362,7 +362,7 @@ var CBTInserter = function (root) {
362
362
return ;
363
363
}
364
364
const q = [root];
365
- while (q .length > 0 ) {
365
+ while (q .length ) {
366
366
const t = [];
367
367
for (const node of q) {
368
368
this .tree .push (node);
Original file line number Diff line number Diff line change @@ -301,7 +301,7 @@ class CBTInserter {
301
301
return ;
302
302
}
303
303
const q: TreeNode [] = [root ];
304
- while (q .length > 0 ) {
304
+ while (q .length ) {
305
305
const t: TreeNode [] = [];
306
306
for (const node of q ) {
307
307
this .tree .push (node );
@@ -355,7 +355,7 @@ var CBTInserter = function (root) {
355
355
return ;
356
356
}
357
357
const q = [root];
358
- while (q .length > 0 ) {
358
+ while (q .length ) {
359
359
const t = [];
360
360
for (const node of q) {
361
361
this .tree .push (node);
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ class CBTInserter {
27
27
}
28
28
}
29
29
}
30
-
30
+
31
31
int insert (int val) {
32
32
auto p = tree[(tree.size () - 1 ) / 2 ];
33
33
auto node = new TreeNode (val);
@@ -39,7 +39,7 @@ class CBTInserter {
39
39
}
40
40
return p->val ;
41
41
}
42
-
42
+
43
43
TreeNode* get_root () {
44
44
return tree[0 ];
45
45
}
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ public CBTInserter(TreeNode root) {
32
32
}
33
33
}
34
34
}
35
-
35
+
36
36
public int insert (int val ) {
37
37
TreeNode p = tree .get ((tree .size () - 1 ) / 2 );
38
38
TreeNode node = new TreeNode (val );
@@ -44,7 +44,7 @@ public int insert(int val) {
44
44
}
45
45
return p .val ;
46
46
}
47
-
47
+
48
48
public TreeNode get_root () {
49
49
return tree .get (0 );
50
50
}
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ var CBTInserter = function (root) {
15
15
return ;
16
16
}
17
17
const q = [ root ] ;
18
- while ( q . length > 0 ) {
18
+ while ( q . length ) {
19
19
const t = [ ] ;
20
20
for ( const node of q ) {
21
21
this . tree . push ( node ) ;
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ class CBTInserter {
20
20
return ;
21
21
}
22
22
const q : TreeNode [ ] = [ root ] ;
23
- while ( q . length > 0 ) {
23
+ while ( q . length ) {
24
24
const t : TreeNode [ ] = [ ] ;
25
25
for ( const node of q ) {
26
26
this . tree . push ( node ) ;
You can’t perform that action at this time.
0 commit comments