2018年11月13日
摘要: 【题目】 Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives 阅读全文
posted @ 2018-11-13 23:44 alau 阅读(134) 评论(0) 推荐(0) 编辑
摘要: ref:https://leetcode.com/problems/binary-tree-postorder-traversal/discuss/45551/Preorder-Inorder-and-Postorder-Iteratively-Summarization Pre Order Tra 阅读全文
posted @ 2018-11-13 19:46 alau 阅读(95) 评论(0) 推荐(0) 编辑
摘要: 【题目】 Given a binary tree, return the preordertraversal of its nodes' values. Example: 【思路】 有参考,好机智,使用堆栈压入右子树,暂时存储。 左子树遍历完成后遍历右子树。 【代码】 阅读全文
posted @ 2018-11-13 18:44 alau 阅读(107) 评论(0) 推荐(0) 编辑
摘要: 【题目】 给出的升序排序的数组,个数必为奇数,要求形成二叉搜索(平衡)树。 【思路】 辅助函数fun,[0,len]=>[0,mid-1]+[mid+1,len]。 当left>right,返回null。 【AC代码】 阅读全文
posted @ 2018-11-13 18:01 alau 阅读(106) 评论(0) 推荐(0) 编辑
摘要: so basically flag-start is size of the roots left subtree, therefore to get the start of right subtree you gotta get to the start of the first value o 阅读全文
posted @ 2018-11-13 17:40 alau 阅读(171) 评论(0) 推荐(0) 编辑