问题描述Given an unsorted array of integers, find the length of the longest consecutive elements sequence. For example,Given [100, 4, 200, 1, 3, 2],The lo...
分类:
其他好文 时间:
2015-08-04 12:46:55
阅读次数:
115
Given a binary tree, imagine yourself standing on therightside of it, return the values of the nodes you can see ordered from top to bottom.For exampl...
分类:
其他好文 时间:
2015-08-03 22:18:49
阅读次数:
105
Given a binary tree, imagine yourself standing on therightside of it, return the values of the nodes you can see ordered from top to bottom.For exampl...
分类:
编程语言 时间:
2015-08-03 18:48:01
阅读次数:
105
Given a binary tree, imagine yourself standing on therightside of it, return the values of the nodes you can see ordered from top to bottom.For exampl...
分类:
其他好文 时间:
2015-08-03 01:04:34
阅读次数:
104
Given a binary tree, find its maximum depth.
The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.
思路:很基础的一个题,DFS即可。代码如下:
/**
* Defin...
分类:
其他好文 时间:
2015-08-01 22:08:25
阅读次数:
140
传送门十分重要的基础DP问题,是学习用各种方式优化DP的一个很好的例子。设DP[i]表示以a[i]结尾的LIS的长度,则状态转移方程为DP[1]=1DP[i] = max{DP[j], j1暴力求解复杂度为O(N^2)。优化1考虑函数f(L):长度为 L 的 Increasing Sequence ...
分类:
其他好文 时间:
2015-08-01 20:28:08
阅读次数:
90
Given a string containing just the characters '(' and ')',
find the length of the longest valid (well-formed) parentheses substring.
For "(()", the longest valid parentheses substring is "()",
...
分类:
其他好文 时间:
2015-08-01 10:07:41
阅读次数:
107
Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest le...
分类:
其他好文 时间:
2015-07-31 16:08:47
阅读次数:
103
Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings.
求最长公共前缀。
代码如下:
class Solution {
public:
string longestCommonPrefix(vect...
分类:
其他好文 时间:
2015-07-30 19:28:27
阅读次数:
109
July 16, 2015Problem statement:Longest Substring Without Repeating CharactersRead the blog:http://blog.csdn.net/fightforyourdream/article/details/1786...
分类:
其他好文 时间:
2015-07-30 14:52:05
阅读次数:
109