GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — leetcode/code/lc589.java at master · mJackie/leetcode Expand file tree/ Copy pathlc589.javaMore file actions 41 lines (35 loc) · 780 Bytes / Copy pathlc589.javaFile metadata and controls41 lines (35 loc) · 780 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 package code; import java.util.ArrayList; import java.util.List; /* * 589. N-ary Tree Preorder Traversal * 题意:多叉树先序遍历 * 难度:Easy * 分类:Tree * 思路: * Tips: */ public class lc589 { class Node { public int val; public List<Node> children; public Node() {} public Node(int _val,List<Node> _children) { val = _val; children = _children; } } List<Integer> res; public List<Integer> preorder(Node root) { res = new ArrayList<>(); helper(root); return res; } public void helper(Node root){ if(root==null) return; res.add(root.val); for(Node nd:root.children){ helper(nd); } } } |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |