由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 这个怎么做?
相关主题
请教一道题目请教道算法题
讨论一道G的题find longest substring which contains just two unique characters.问几个phone screening的问题
今天晚上要不然研究一下这题?Minimum Window Substring
LeetCode LongestValidParenthesesMinimum Window Substring (from leetcode)
帮忙看看为撒 leetcode OJ time out "Substring with Concatenation of All Words "(已解决,code错了) online judge 有的时候会有点小bug吗?
问一道算法题max length of subsequence string matching subsminimum window substring
MS面试题一个code challenge
一个Google面试题上道题:非Minimum Window Substring
相关话题的讨论汇总
话题: substrings话题: ccdaabcdbb话题: length话题: output话题: minimum
进入JobHunting版参与讨论
1 (共1页)
a*****a
发帖数: 46
1
一道题:You are given a string S and a set of n substrings. You are supposed
to remove every instance of those n substrings from S so that S is of the
minimum length and output this minimum length. Eg: S- ccdaabcdbb n=2 -
substrings– (ab, cd)Output: 2 Explanation: ccdaabcdbb -> ccdacdbb -> cabb -
> cb (length=2)
j******7
发帖数: 15
2
刚学python,菜鸟一个,见笑了。
str="Heeololeo"
sub=["ol","ee"]
for i in range(len(sub)-1):
for j in range(len(str)-1):
if str[j:j+len(sub[i])]==sub[i]:
str=str.replace(sub[i],"")
return str
上面的循环只能去掉ol,无法执行第二次大循环。
而且感觉还应该在最外面加一个循环,break条件是 sub[i]不再是最近一次结果的
substring。

supposed
-

【在 a*****a 的大作中提到】
: 一道题:You are given a string S and a set of n substrings. You are supposed
: to remove every instance of those n substrings from S so that S is of the
: minimum length and output this minimum length. Eg: S- ccdaabcdbb n=2 -
: substrings– (ab, cd)Output: 2 Explanation: ccdaabcdbb -> ccdacdbb -> cabb -
: > cb (length=2)

1 (共1页)
进入JobHunting版参与讨论
相关主题
上道题:非Minimum Window Substring帮忙看看为撒 leetcode OJ time out "Substring with Concatenation of All Words "
Minimum Window Substring 这题目算法导论书上有么?问一道算法题max length of subsequence string matching subs
G面经MS面试题
面试google面试的郁闷一个Google面试题
请教一道题目请教道算法题
讨论一道G的题find longest substring which contains just two unique characters.问几个phone screening的问题
今天晚上要不然研究一下这题?Minimum Window Substring
LeetCode LongestValidParenthesesMinimum Window Substring (from leetcode)
相关话题的讨论汇总
话题: substrings话题: ccdaabcdbb话题: length话题: output话题: minimum