![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
lintcode
SEMPERFI_5407
这个作者很懒,什么都没留下…
展开
-
lintcode python— 最长公共字符串
最长公共字符串问题描述:给出两个字符串,找到最长公共子串,并返回其长度。代码如下:class Solution: def longestCommonSubstring(self, A, B): l= [] if A == '' or B == '': #排除特殊情况 return '',0 fo原创 2017-02-11 14:45:22 · 881 阅读 · 0 评论 -
lintcode python— 两个字符串是变位词
问题描述:写出一个函数 anagram(s, t) 判断两个字符串是否可以通过改变字母的顺序变成一样的字符串。样例给出 s = "abcd",t="dcab",返回 true.给出 s = "ab", t = "ab", 返回 true.给出 s = "ab", t = "ac", 返回 false.class Solution: def anagram(s原创 2017-02-11 15:04:20 · 2179 阅读 · 0 评论 -
llintcode python——字符串查找
字符串查找(查找子字符串)问题描述:问题描述:对于一个给定的 source 字符串和一个 target 字符串,你应该在 source字符串中找出 target 字符串出现的第一个位置(从0开始)。如果不存在,则返回 -1。代码如下:class Solution: def strStr(self, source, target): A = source原创 2017-02-11 15:12:48 · 760 阅读 · 0 评论 -
lintcode python ——最长公共前缀(LCP)
问题描述:给k个字符串,求出他们的最长公共前缀(LCP)样例在 "ABCD" "ABEF" 和 "ACEF" 中, LCP 为 "A"在 "ABCDEFG", "ABCEFG", "ABCEFA" 中, LCP 为 "ABC"class Solution: def longestCommonPrefix(self, strs): n = 0原创 2017-02-12 14:43:18 · 1756 阅读 · 0 评论