2018年8月16日

314. Binary Tree Vertical Order Traversal

摘要: use two stacks 阅读全文

posted @ 2018-08-16 23:57 猪猪🐷 阅读(97) 评论(0) 推荐(0)

108. Convert Sorted Array to balanced Binary Search Tree

摘要: 带返回值的 recursion Given an array where elements are sorted in ascending order, convert it to a height balanced BST. For this problem, a height-balanced 阅读全文

posted @ 2018-08-16 23:54 猪猪🐷 阅读(85) 评论(0) 推荐(0)

binary search tree to sorted double linked list (not circular) (okay)

摘要: TreeNode head = null; TreeNode prev = null; public void inOrder(TreeNode root){ if(root == null) return; inOrder(root.left); if(prev == null){ head = root; }else{ prev.right = root... 阅读全文

posted @ 2018-08-16 23:52 猪猪🐷 阅读(129) 评论(0) 推荐(0)

109. Convert Sorted List to Binary Search Tree

摘要: Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. For this problem, a height-balanced bina 阅读全文

posted @ 2018-08-16 23:51 猪猪🐷 阅读(96) 评论(0) 推荐(0)

Convert Sorted double linked List to Binary Search Tree

摘要: 把自己写的solution 1 和 闫老师写的solution2 都弄懂,会写。 bst变double linked list。recursion秒了,然后第一个follow up是把双链表变回去,要求balance。第二个follow up是在牺牲空间复杂度的情况下如何优化时间,想了个时间O(n) 阅读全文

posted @ 2018-08-16 23:49 猪猪🐷 阅读(180) 评论(0) 推荐(0)

previous and next permutation

摘要: Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not possib 阅读全文

posted @ 2018-08-16 23:45 猪猪🐷 阅读(169) 评论(0) 推荐(0)

301. Remove Invalid Parentheses

摘要: 301. Remove Invalid Parentheses Remove the minimum number of invalid parentheses in order to make the input string valid. Return all possible results. Note: The input string may contain letters oth... 阅读全文

posted @ 2018-08-16 23:44 猪猪🐷 阅读(188) 评论(0) 推荐(0)

导航