摘要: Given a binary tree, return the postorder traversal of its nodes' values. For example:Given binary tree {1,#,2,3}, return [3,2,1]. 思路:后序遍历 阅读全文
posted @ 2016-10-09 10:31 Machelsky 阅读(132) 评论(0) 推荐(0)
摘要: Given a binary tree, return the inorder traversal of its nodes' values. For example:Given binary tree [1,null,2,3], return [1,3,2]. 思路:中序遍历。 阅读全文
posted @ 2016-10-09 10:26 Machelsky 阅读(106) 评论(0) 推荐(0)
摘要: Given a binary tree, return the preorder traversal of its nodes' values. For example:Given binary tree {1,#,2,3}, return [1,2,3]. Note: Recursive solu 阅读全文
posted @ 2016-10-09 10:17 Machelsky 阅读(101) 评论(0) 推荐(0)
摘要: Compare two version numbers version1 and version2.If version1 > version2 return 1, if version1 < version2 return -1, otherwise return 0. You may assum 阅读全文
posted @ 2016-10-09 10:01 Machelsky 阅读(170) 评论(0) 推荐(0)
摘要: The set [1,2,3,…,n] contains a total of n! unique permutations. By listing and labeling all of the permutations in order,We get the following sequence 阅读全文
posted @ 2016-10-09 06:05 Machelsky 阅读(99) 评论(0) 推荐(0)
摘要: We are playing the Guess Game. The game is as follows: I pick a number from 1 to n. You have to guess which number I picked. Every time you guess wron 阅读全文
posted @ 2016-10-09 04:35 Machelsky 阅读(160) 评论(0) 推荐(0)
摘要: Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. Given a singly linked list where element 阅读全文
posted @ 2016-10-09 03:48 Machelsky 阅读(137) 评论(0) 推荐(0)
摘要: Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in or 阅读全文
posted @ 2016-10-09 03:36 Machelsky 阅读(119) 评论(0) 推荐(0)
摘要: Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. 阅读全文
posted @ 2016-10-09 03:26 Machelsky 阅读(141) 评论(0) 推荐(0)
摘要: Given a list, rotate the list to the right by k places, where k is non-negative. For example:Given 1->2->3->4->5->NULL and k = 2,return 4->5->1->2->3- 阅读全文
posted @ 2016-10-09 03:02 Machelsky 阅读(129) 评论(0) 推荐(0)
摘要: 190. Reverse Bits:原数向右移动,如果bit是1,就给结果在相应的位置加上1. 46. Permutations:最适合这道题的dfs搜索顺序是把加一个限制条件:搜索过的数字跳过。脑子里面有个tree的模型然后去想应该搜索的顺序和条件。 100. Same Tree: 递归:检查是不 阅读全文
posted @ 2016-10-09 02:34 Machelsky 阅读(83) 评论(0) 推荐(0)
摘要: The gray code is a binary numeral system where two successive values differ in only one bit. Given a non-negative integer n representing the total num 阅读全文
posted @ 2016-10-09 02:25 Machelsky 阅读(139) 评论(0) 推荐(0)