码迷,mamicode.com
首页 >  
搜索关键字:longest ordered subs    ( 3212个结果
[ LeetCode ] Longest Common Prefix
题目 Write a function to find the longest common prefix string amongst an array of strings. 原题链接 解题思想 给一个字符串数组,求这些字符串的最长公共前缀。 这个题应该是比较简单的,直接写代码,一次AC。解题思想是依次对数组中的字符串求最长公共前缀。 代码实现 class Sol...
分类:其他好文   时间:2014-06-20 12:25:09    阅读次数:247
[LeetCode] Longest Valid Parentheses
第一种方法,用栈实现,最容易想到,也比较容易实现,每次碰到‘)’时update max_len,由于要保存之前的‘(’的index,所以spacecomplexity 是O(n) 1 // 使用栈,时间复杂度 O(n),空间复杂度 O(n) 2 class Solution { 3 publ...
分类:其他好文   时间:2014-06-11 09:16:10    阅读次数:197
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 ro...
分类:其他好文   时间:2014-06-10 10:09:13    阅读次数:237
Leetcode:Longest Common Prefix 最长公共前缀
戳我去解题Write a function to find the longest common prefix string amongst an array of strings.class Solution {public: string longestCommonPrefix(vecto...
分类:其他好文   时间:2014-06-10 08:29:55    阅读次数:189
Leetcode::Longest Common Prefix && Search for a Range
一次总结两道题,两道题目都比较基础Description:Write a function to find the longest common prefix string amongst an array of strings.分析: 这道题目最重要的知道什么叫prefix前缀, 否则一不小心就做...
分类:其他好文   时间:2014-06-09 21:08:16    阅读次数:224
swift中文文档翻译之--字符串和字符
字符串和字符A string is an ordered collection of characters, such as "hello, world" or "albatross". Swift strings are represented by the String type, which ...
分类:其他好文   时间:2014-06-08 19:43:21    阅读次数:247
leetcode——Longest Substring Without Repeating Characters 求链表中无重复字符的最大字串长度(AC)
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. Fo...
分类:其他好文   时间:2014-06-08 16:27:47    阅读次数:231
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. 方法 使用DFS对树进行遍...
分类:其他好文   时间:2014-06-08 10:26:33    阅读次数:207
[LeetCode] Longest Substring Without Repeating Characters [15]
题目:Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. For "bbbbb" the longest substring is "b", with the length...
分类:其他好文   时间:2014-06-08 03:06:52    阅读次数:221
[LeetCode] Longest Palindromic Substring [14]
最长回文字串,相信做过Palindrome Partitioning II 这个题的同学应该可以很快做出来。没错,这个题还可以使用动态规划方法得到一个时间复杂度为O(n^2)的解法,当然如果你想要更好的时间复杂度的算法也是有的。好的,我们先来看看时间复杂度为O(n^2)的算法。 代码实现--动态规划O(n^2) 相信如果你在网上看过了别人的算法,你会发现我的算法是最简洁的。哈哈,这个题需要注意的是如果你用惯了vector的话,你这里肯定会得到超时的提示... ...代码二--复杂度为O(n)的算法...
分类:其他好文   时间:2014-06-07 12:08:43    阅读次数:224
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!