C
C#2y ago
morry329#

❔ a small hint requested

I tried to resolve this LeetCode puzzle https://leetcode.com/problems/binary-tree-level-order-traversal/?envType=study-plan&id=level-1 And my code is full of errors
public class Solution {
public IList<IList<int>> LevelOrder(TreeNode root) {
List<int> tree = new List<int>();
List<int> separation = new List<int>();
Queue<int> numbers = new Queue<int>();
TreeNode node = new TreeNode();
numbers.Add(root.val);
if(root == null){
return tree;
}

while(root.Count > 0){
numbers.Enqueue(node.left);
numbers.Enqueue(node.right);
if(node.left == null || node.right == null){
continue;
}

}
separation.Add(numbers);
tree.Add(separation);
return tree;
}
}
public class Solution {
public IList<IList<int>> LevelOrder(TreeNode root) {
List<int> tree = new List<int>();
List<int> separation = new List<int>();
Queue<int> numbers = new Queue<int>();
TreeNode node = new TreeNode();
numbers.Add(root.val);
if(root == null){
return tree;
}

while(root.Count > 0){
numbers.Enqueue(node.left);
numbers.Enqueue(node.right);
if(node.left == null || node.right == null){
continue;
}

}
separation.Add(numbers);
tree.Add(separation);
return tree;
}
}
Could anyone kindly provide some pointers for me? I feel like starting to bang my head against my keyboard lol
LeetCode
LeetCode - The World's Leading Online Programming Learning Platform
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
1 Reply
Accord
Accord2y ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server