D - Throwing cards away I Given is an ordered deck of n cards numbered 1 to n with card 1 at the top and card n at the bottom. The following operation ...
题: 遍历比较。 一本正经地说一下思路。 最长前缀。 一旦找到一个不匹配,就无法做成最长前缀。 所有我们的目的就是去找这个不匹配。 注意一下字符串为空的情况,每次都会栽在这里。 为了提高效率,找出最短字符串,因为最长前缀的长度不可能超过最短字符串的长度。 哎,心累。没有用例。 ...
分类:
编程语言 时间:
2017-05-11 22:24:47
阅读次数:
126
Write a function to find the longest common prefix string amongst an array of strings. 思路: 首先得到最短的字符串长度length,然后从0开始到length长度 挨个比较每一个字符是否相等。 ...
分类:
其他好文 时间:
2017-05-11 17:00:31
阅读次数:
132
Given two strings a and b of equal length, what’s the longest string (S) that can be constructed such that S is a child to both a and b. String x is s ...
分类:
其他好文 时间:
2017-05-11 13:31:29
阅读次数:
175
Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path betwe ...
分类:
其他好文 时间:
2017-05-11 11:43:48
阅读次数:
161
Manacher算法,实现最长回文字符串检测的算法。算法实现在Gcc编译环境下运行出现错误,但是在VC环境下运行正常。 出错的情形如下图所示: ...
分类:
其他好文 时间:
2017-05-11 00:17:47
阅读次数:
228
3. Longest Substring Without Repeating Characters Given a string, find the length of the longest substring without repeating characters. Examples: Giv ...
分类:
其他好文 时间:
2017-05-09 11:23:13
阅读次数:
131
Problem statement: Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Example: Exampl ...
分类:
其他好文 时间:
2017-05-09 11:16:06
阅读次数:
115
最长回文字串 上题: 测试用例中,注意aaabaaaa。 但是我time limit exceeded。用了极暴力的方法解。(三层循环)找每一个字符的最长回文字串。 1 /** 2 * 最长回文子串 3 * 2017-5-7 4 **/ 5 6 import java.io.*; 7 import ...
分类:
编程语言 时间:
2017-05-07 15:36:29
阅读次数:
179
Homer: Marge, I just figured out a way to discover some of the talents we weren’t aware we had. Marge: Yeah, what is it? Homer: Take me for example. I ...
分类:
其他好文 时间:
2017-05-06 23:06:01
阅读次数:
215