1 class Solution { 2 public: 3 /** 4 * @param strs: A list of strings 5 * @return: The longest common prefix 6 */ 7 string...
分类:
其他好文 时间:
2015-06-29 16:36:19
阅读次数:
197
Write a function to find the longest common prefix string amongst an array of strings.直接按第一个元素开始比较,最后截取符合要求的前段。var longestCommonPrefix = function(strs...
分类:
其他好文 时间:
2015-06-29 11:32:33
阅读次数:
82
题意很简单,就是寻找一个字符串中连续的最长包含不同字母的子串。其实用最朴素的方法,从当前字符开始寻找,找到以当前字符开头的最长子串。这个方法猛一看是个n方的算法,但是要注意到由于字符数目的限制,其实这是个O(Cn)的算法,最长也不过是C长度。所以我觉得普通方法应该是能过的。于是写了一个,字符数目最大...
分类:
其他好文 时间:
2015-06-29 00:23:08
阅读次数:
107
1 class Solution { 2 public: 3 /** 4 * @param A, B: Two strings. 5 * @return: The length of longest common subsequence of A and B. 6 ...
分类:
其他好文 时间:
2015-06-28 17:04:49
阅读次数:
107
1 class Solution { 2 public: 3 /** 4 * @param A, B: Two string. 5 * @return: the length of the longest common substring. 6 */ ...
分类:
其他好文 时间:
2015-06-28 17:00:49
阅读次数:
94
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-06-27 06:24:03
阅读次数:
127
题意:给多个字符串,返回这些字符串的最长公共前缀。思路:直接逐个统计同一个位置上的字符有多少种,如果只有1种,那么就是该位是相同的,进入下一位比较。否则终止比较,返回前缀。可能有一个字符串会比较短,所以前缀最长也只是最短字符串的长度。 1 class Solution { 2 public: 3 ....
分类:
其他好文 时间:
2015-06-27 01:16:45
阅读次数:
268
【LeetCode】Longest Substring Without Repeating Characters
Given a string, find the length of the longest substring without repeating characters.
查找给定字符串中最长的无重复字符的子串...
分类:
其他好文 时间:
2015-06-26 16:22:02
阅读次数:
103
1. String getOrderedString(boolean isDuplicated, String … str)
说明:
Orders all characters in the input strings and return the ordered string.(note: only considering the alphabets and digits)
i.e:
...
分类:
编程语言 时间:
2015-06-25 15:43:48
阅读次数:
123
// 1、判断strs的长度,如果为0则返回空字符
// 2、找出strs中最短的字串
// 3、采用循环查询的方式依次匹配是否和最短字串相符
// 4、循环中实时更新查询的长度index#include
#include
#include char* longestCommonPrefix(char** strs, int str...
分类:
其他好文 时间:
2015-06-25 14:08:29
阅读次数:
195