Skip to content

Commit 18aca55

Browse files
authored
Fix 102-binary-tree-level-order-traversal.js empty array error
1 parent e815ef4 commit 18aca55

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

javascript/102-Binary-Tree-Level-Order-Traversal.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
*/
1313
var levelOrder = function(root) {
1414

15+
if(!root) return [];
16+
1517
const result = [];
1618
const queue = [root];
1719

0 commit comments

Comments
 (0)