Source:https://oj.leetcode.com/problems/longest-common-prefix/Write a function to find the longest common prefix string amongst an array of strings.Hi...
分类:
编程语言 时间:
2014-10-14 00:46:47
阅读次数:
306
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-10-12 17:54:08
阅读次数:
177
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters fo...
分类:
其他好文 时间:
2014-10-12 17:16:38
阅读次数:
155
It is lunch time for Mole. His friend, Marmot, prepared him a nice game for lunch.
Marmot brought Mole n ordered piles of worms such that i-th
pile contains ai worms.
He labeled all these worms...
分类:
其他好文 时间:
2014-10-11 23:58:16
阅读次数:
361
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 longest...
分类:
其他好文 时间:
2014-10-11 14:52:35
阅读次数:
167
Problem:Given a stringS, find the longest palindromic substring inS. You may assume that the maximum length ofSis 1000, and there exists one unique lo...
分类:
其他好文 时间:
2014-10-11 02:20:24
阅读次数:
227
这题看起来挺简单的,就是存一个哈希表,然后依次遍历整个字符串,遇到前面有过的字符的时候,就该停止当前计数,新的子串应该从发现该字符的位置的下一位置开始。我开始写了一个简单的写法,发现超时了: if (s.empty()) return 0; if (s.length() == 1) retur.....
分类:
其他好文 时间:
2014-10-10 14:28:10
阅读次数:
160
题目链接:
here
题意:
和hdu4742类似。区别就是一部分三元组是直接给出的。还有一部分是用他给的那个函数生成的。还有就是这里的大于是严格的大于a>b必须ax>bx,ay>by,az>bz。
思路:
思路也和hdu4742here类似。只是有几个比较棘手的问题。现在变成严格大于了。对于y还是很好办的。我们在排序y的时候可以使的标号大的排在前面这样就可以防止y和它一样的更新它了...
分类:
其他好文 时间:
2014-10-10 02:52:43
阅读次数:
235
[leetcode]
Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring....
分类:
其他好文 时间:
2014-10-09 17:06:08
阅读次数:
187
class Solution: # @return a string def longestCommonPrefix(self, strs): num_items=len(strs) if num_itemslen(i): pre...
分类:
其他好文 时间:
2014-10-09 15:05:24
阅读次数:
179