码迷,mamicode.com
首页 >  
搜索关键字:longest ordered subs    ( 3212个结果
[LeetCode]Maximum Depth of Binary Tree
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. /** * Definition for binary tree ...
分类:其他好文   时间:2014-08-02 23:32:04    阅读次数:232
HDU 1087 && POJ 2533(DP,最长上升子序列).
~~~~ 两道题的意思差不多,HDU上是求最长上升子序列的和,而POJ上就的是其长度。 貌似还有用二分写的nlogn的算法,不过这俩题n^2就可以过嘛。。 ~~~~ 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1087 http://poj.org/problem?id=2533 ~~~~ HDU1087: #include...
分类:其他好文   时间:2014-08-02 23:30:15    阅读次数:243
[leetcode]Longest Valid Parentheses
Longest Valid ParenthesesGiven a string containing just the characters'('and')', find the length of the longest valid (well-formed) parentheses substr...
分类:其他好文   时间:2014-08-02 04:22:40    阅读次数:248
LeetCode--Longest Palindromic Substring
有一个比较容易出错的点:反转求最长公共子序列,这是错误的想法 1 class Solution { 2 public: 3 string longestPalindrome(string s) { 4 int n = s.length(); 5 int lon...
分类:其他好文   时间:2014-08-01 15:28:31    阅读次数:214
(算法竞赛入门经典 优先队列)LA 3135(前K条指令)
A data stream is a real-time, continuous, ordered sequence of items. Some examples include sensor data, Internet traffic, financial tickers, on-line auctions, and transaction logs such as Web usage lo...
分类:其他好文   时间:2014-08-01 13:47:14    阅读次数:235
[leetcode]Longest Palindromic Substring
Longest Palindromic SubstringGiven a stringS, find the longest palindromic substring inS. You may assume that the maximum length ofSis 1000, and there...
分类:其他好文   时间:2014-08-01 04:47:25    阅读次数:243
[leetcode]Longest Substring Without Repeating Characters
Longest Substring Without Repeating CharactersGiven a string, find the length of the longest substring without repeating characters. For example, the ...
分类:其他好文   时间:2014-07-31 23:46:00    阅读次数:256
[leetcode]Longest Common Prefix
Longest Common PrefixWrite a function to find the longest common prefix string amongst an array of strings.算法思路:思路:貌似木有什么捷径,逐个比较,遇到不同即断开。代码如下: 1 publi...
分类:其他好文   时间:2014-07-31 23:31:50    阅读次数:231
[leetcode]Maximum Depth of Binary Tree
Maximum Depth of Binary TreeGiven a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root ...
分类:其他好文   时间:2014-07-31 23:19:10    阅读次数:259
Longest Consecutive Sequence
其实网上关于leetcode的题目的答案已经相当多了,这也是为啥我自己不把每道题目都贴出来的原因,觉得分析得没人好,代码也没别人的精简。不过,这道题目看到网上有不少做法跟实际要求的O(n)复杂度不太符合,所以特别粘贴出来,也正好记录下自己的一些想法。   说实话,在第二遍做这道题目的时候,我还是没能够把最为完善的解法想出来,能够想到的是利用hash表以序列值为key,1(只是简单做个标记)为v...
分类:其他好文   时间:2014-07-31 21:01:41    阅读次数:165
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!