✅ A bunch of syntax errors
I am trying to solve this puzzle https://leetcode.com/problems/n-ary-tree-preorder-traversal/
I got a couple of syntax errors at the foreach loop (like I am missing ; or , etc), but I have no idea how to apply the variable val assigned by LeetCode. Could anyone kindly point me some directions?
`
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.
8 Replies
Well that doesn't look right for one thing
root.value
is not a variable.
foreach should be doing something like:
or something like that.Thanks a lot for your guide 🙏
I will try that again
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.One more question - my current code is like this right now `
And I got null array [] returned instead of the pre-ordered array
Could you kindly give me some hints again as to why my code returns something so null?
You never add anything to the list
[]
means empty not nullWas this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.Thank you so much - I managed to get it solved
Here is my code
`