这一章暂时没写完,先留着以后再写。在C++程序中,程序员可以给手动开辟内存,但是这块内存需要手动释放,不便管理,因此新标准提供智能指针类型来管理动态对象。它负责自动释放所指向的对象。shared_prt允许多个指针指向同一个对象unique_ptr独占所指向的对象weak_ptr是一个弱引用,指向s...
分类:
编程语言 时间:
2014-09-09 21:28:39
阅读次数:
413
Problem Description:
Given a collection of numbers that might contain duplicates, return all possible unique permutations.
For example,
[1,1,2] have the following unique permutations:
[1,1,2...
分类:
其他好文 时间:
2014-09-09 16:17:29
阅读次数:
200
Given n, generate all structurally unique BST's (binary search trees) that store values 1...n.
For example,
Given n = 3, your program should return all 5 unique BST's shown below.
1 3...
分类:
其他好文 时间:
2014-09-09 12:31:39
阅读次数:
143
Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longes...
分类:
其他好文 时间:
2014-09-09 12:14:08
阅读次数:
200
Combination SumGiven a set of candidate numbers (C) and a target number (T), find all unique combinations inCwhere the candidate numbers sums toT.Thes...
分类:
其他好文 时间:
2014-09-09 10:54:08
阅读次数:
190
思路: 其实答案就是 C(m+n-2, m-1). 但是写程序利用动态规划会简单快捷。(给两个代码,第一个方便理解,第二个是基于第一个的优化)
思路:同上,只是最初初始化全 0 . 当前位置为 1 时,则当到达前位置的步数为 0.
分类:
其他好文 时间:
2014-09-09 10:29:48
阅读次数:
255
Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example,[1,1,2] have the following unique per...
分类:
其他好文 时间:
2014-09-08 00:55:26
阅读次数:
269
public class Solution { public int uniquePaths(int m, int n) { int [][] result = new int[m][n]; for (int i=0; i<m; i++) { ...
分类:
其他好文 时间:
2014-09-07 14:42:25
阅读次数:
181
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of ...
分类:
其他好文 时间:
2014-09-07 14:40:25
阅读次数:
188
Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array whic...
分类:
其他好文 时间:
2014-09-07 12:13:15
阅读次数:
209