© 2026 Hedgehog Software, LLC
public class Solution { public IList<int> Preorder(Node root) { List<int> ans = new List<int>(); if(root == null){ return ans; } Helper(root, ans); return ans; } public void Helper(Node root, List<int> ans){ foreach(var node in root.children){ ans.Add(node.val); Helper(node, ans); } } }