问题描述:
Given inorder and postorder traversal of a tree, construct the binary tree.
Note:
You may assume that duplicates do not exist in the tree.
基本思路:
与前一篇《Construct Binary Tree from Preord...
分类:
其他好文 时间:
2014-11-23 11:51:28
阅读次数:
172
问题描述:
Given preorder and inorder traversal of a tree, construct the binary tree.
Note:
You may assume that duplicates do not exist in the tree.
基本思路:
找到规律,递归的解决左子树和右子树。
代码:
/**
* D...
分类:
其他好文 时间:
2014-11-23 10:32:58
阅读次数:
190
Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example,[1,1,2]have the following unique perm...
分类:
其他好文 时间:
2014-11-22 20:11:58
阅读次数:
180
这个题目其实不难的,主要是我C++的水平太差了,链表那里绊了好久,但是又不像用python,所以还是强行上了。 题目如下: Given a sorted linked list, delete all duplicates such that each element appear only onc...
分类:
其他好文 时间:
2014-11-22 17:16:55
阅读次数:
177
Follow up for "Find Minimum in Rotated Sorted Array":What if duplicates are allowed?Would this affect the run-time complexity? How and why?前面那道题:Find ...
分类:
其他好文 时间:
2014-11-22 11:59:28
阅读次数:
162
Follow up for "Find Minimum in Rotated Sorted Array":What if duplicates are allowed?Would this affect the run-time complexity? How and why?Suppose a s...
分类:
其他好文 时间:
2014-11-22 07:03:46
阅读次数:
206
1 class Solution { 2 public: 3 int removeDuplicates(int A[], int n) { 4 int *s=&A[0],*e=&A[0]; //s指向开头第一个,e往后遍历相同的 5 int t,i,j=n; 6 fo...
分类:
编程语言 时间:
2014-11-22 00:40:25
阅读次数:
215
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....
分类:
其他好文 时间:
2014-11-21 14:03:57
阅读次数:
160
Follow up for "Remove Duplicates":
What if duplicates are allowed at most twice?
For example,
Given sorted array A = [1,1,1,2,2,3],
Your function should return length = 5, and A is now [1,1,2,...
分类:
其他好文 时间:
2014-11-20 17:07:45
阅读次数:
194
Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.
Do not allocate extra space for another array, you must do this in place with...
分类:
其他好文 时间:
2014-11-20 17:07:03
阅读次数:
218