上一页 1 2 3 4 5 6 7 8 9 10 ··· 33 下一页
摘要: class Solution { Node pre, head; public Node treeToDoublyList(Node root) { if(root == null) return null; dfs(root); head.left = pre; pre.right = head; 阅读全文
posted @ 2020-08-20 10:02 欣姐姐 阅读(93) 评论(0) 推荐(0) 编辑
摘要: // Encodes a tree to a single string. public String serialize(TreeNode root) { if(root == null) return "[]"; Deque<TreeNode> deque = new LinkedList<>( 阅读全文
posted @ 2020-08-20 10:01 欣姐姐 阅读(111) 评论(0) 推荐(0) 编辑
摘要: class Solution { HashMap<Node,Node> map = new HashMap<>(); public Node copyRandomList(Node head) { if(head == null) return null; Node p = head; while( 阅读全文
posted @ 2020-08-19 15:58 欣姐姐 阅读(87) 评论(0) 推荐(0) 编辑
摘要: List<List<Integer>> res = new ArrayList<>(); public List<List<Integer>> pathSum(TreeNode root, int sum) { List<Integer> list = new ArrayList<>(); trac 阅读全文
posted @ 2020-08-18 11:25 欣姐姐 阅读(114) 评论(0) 推荐(0) 编辑
摘要: class Solution { public boolean verifyPostorder(int[] postorder) { int n = postorder.length; if(n<=1) return true; int j = n-1; for(;j>=0;j--){ if(pos 阅读全文
posted @ 2020-08-18 09:57 欣姐姐 阅读(107) 评论(0) 推荐(0) 编辑
摘要: List<List<Integer>> res = new ArrayList<>(); public List<List<Integer>> levelOrder(TreeNode root) { if(root == null) return res; Deque<TreeNode> queue 阅读全文
posted @ 2020-08-17 23:30 欣姐姐 阅读(106) 评论(0) 推荐(0) 编辑
摘要: class Solution { public List<List<Integer>> levelOrder(TreeNode root) { List<List<Integer>> res = new ArrayList<>(); if(root == null) return res; Queu 阅读全文
posted @ 2020-08-17 22:23 欣姐姐 阅读(92) 评论(0) 推荐(0) 编辑
摘要: public int[] levelOrder(TreeNode root) { Deque<TreeNode> deque = new ArrayDeque<>(); ArrayList<Integer> res = new ArrayList<>(); if(root != null){ deq 阅读全文
posted @ 2020-08-17 22:11 欣姐姐 阅读(77) 评论(0) 推荐(0) 编辑
摘要: public boolean validateStackSequences(int[] pushed, int[] popped) { int m = pushed.length; int n = popped.length; if(m!=n) return false; if(m == 1) re 阅读全文
posted @ 2020-08-17 21:15 欣姐姐 阅读(162) 评论(0) 推荐(0) 编辑
摘要: public class MinStack { /** initialize your data structure here. */ Stack<Integer> stack = new Stack<>(); private int min = Integer.MIN_VALUE; List<In 阅读全文
posted @ 2020-08-10 21:57 欣姐姐 阅读(114) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 10 ··· 33 下一页