Follow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?
分类:
其他好文 时间:
2014-07-10 11:10:26
阅读次数:
302
Problem Description:Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.Solution: 递归。 1 public List>...
分类:
其他好文 时间:
2014-07-07 16:59:12
阅读次数:
169
原始指针:通过new建立的*指针智能指针:通过智能指针关键字(unique_ptr, shared_ptr ,weak_ptr)建立的指针在现代 C++ 编程中,标准库包含智能指针,该指针用于确保程序不存在内存和资源泄漏且是异常安全的。在现代 C++ 中,原始指针仅用于范围有限的小代码块、循环或者性...
分类:
编程语言 时间:
2014-06-30 13:49:42
阅读次数:
354
题目链接:点击打开链接
题意:给定一棵树
找2条点不重复的路径,使得两路径的长度乘积最大
思路:
1、为了保证点不重复,在图中删去一条边,枚举这条删边
2、这样得到了2个树,在各自的树中找最长链,即树的直径,然后相乘即可
#include
#include
#include
#include
#include
#include
#include
#include
#include
#i...
分类:
其他好文 时间:
2014-06-30 07:30:01
阅读次数:
235
Given a stringS, find the longest palindromic substring inS. You may assume that the maximum length ofSis 1000, and there exists one unique longest pa...
分类:
其他好文 时间:
2014-06-29 20:28:58
阅读次数:
183
Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.
For example:
Given the below binary tree and sum
= 22,
5
/ ...
分类:
其他好文 时间:
2014-06-28 07:31:28
阅读次数:
214
题目
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], [1,2,1],
...
分类:
其他好文 时间:
2014-06-27 23:53:21
阅读次数:
290
The set [1,2,3,…,n] contains a total of n! unique permutations.
分类:
其他好文 时间:
2014-06-27 11:49:18
阅读次数:
152
Given a collection of numbers that might contain duplicates, return all possible unique permutations.
分类:
其他好文 时间:
2014-06-27 11:47:58
阅读次数:
166
题目
Write a program to solve a Sudoku puzzle by filling the empty cells.
Empty cells are indicated by the character '.'.
You may assume that there will be only one unique solution.
...
分类:
其他好文 时间:
2014-06-27 07:06:50
阅读次数:
184