Construct Binary Tree from Inorder and Postorder Traversal

摘要: Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree. 1 class Solut... 阅读全文
posted @ 2014-08-17 00:12 Ryan-Xing 阅读(135) 评论(0) 推荐(0) 编辑

Construct Binary Tree from Preorder and Inorder Traversal

摘要: Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.分析:通过一个二叉树的先序遍历... 阅读全文
posted @ 2014-08-16 23:28 Ryan-Xing 阅读(159) 评论(0) 推荐(0) 编辑

Combination Sum

摘要: Given a set of candidate numbers (C) and a target number (T), find all unique combinations inCwhere the candidate numbers sums toT.Thesamerepeated num... 阅读全文
posted @ 2014-08-16 16:33 Ryan-Xing 阅读(112) 评论(0) 推荐(0) 编辑

Partition List

摘要: Given a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater than or equal tox.You should preserve the origi... 阅读全文
posted @ 2014-08-16 15:58 Ryan-Xing 阅读(197) 评论(0) 推荐(0) 编辑

Binary Tree Zigzag Level Order Traversal

摘要: Given a binary tree, return thezigzag level ordertraversal of its nodes' values. (ie, from left to right, then right to left for the next level and al... 阅读全文
posted @ 2014-08-16 00:15 Ryan-Xing 阅读(112) 评论(0) 推荐(0) 编辑

Triangle

摘要: Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the fol... 阅读全文
posted @ 2014-08-15 23:26 Ryan-Xing 阅读(227) 评论(0) 推荐(0) 编辑

Subsets II

摘要: Given a collection of integers that might contain duplicates,S, return all possible subsets.Note:Elements in a subset must be in non-descending order.... 阅读全文
posted @ 2014-08-15 20:39 Ryan-Xing 阅读(364) 评论(0) 推荐(0) 编辑

3Sum Closest

摘要: Given an arraySofnintegers, find three integers inSsuch that the sum is closest to a given number, target. Return the sum of the three integers. You m... 阅读全文
posted @ 2014-08-15 19:26 Ryan-Xing 阅读(138) 评论(0) 推荐(0) 编辑

abs(INT_MAX-(-1))

摘要: 写一个程序,结果总是不对,check逻辑好几遍也没发现错误,无奈之下debug。发现一个有趣的现象abs(INT_MAX-(-1))返回值是-2147483648。于是看了下abs函数的代码实现。1 int __cdecl abs (2 int number3 )4 ... 阅读全文
posted @ 2014-08-15 17:03 Ryan-Xing 阅读(578) 评论(0) 推荐(0) 编辑

Unique Binary Search Tree II

摘要: Givenn, generate all structurally uniqueBST's(binary search trees) that store values 1...n.For example,Givenn= 3, your program should return all 5 uni... 阅读全文
posted @ 2014-08-14 17:00 Ryan-Xing 阅读(191) 评论(0) 推荐(0) 编辑