首页 > 其他 > 详细

[Leetcode] Substring with Concatenation of All Words

时间:2014-10-01 15:45:41      阅读:236      评论:0      收藏:0      [点我收藏+]

You are given a string, S, and a list of words, L, that are all of the same length. Find all starting indices of substring(s) in S that is a concatenation of each word in L exactly once and without any intervening characters.

For example, given:
S"barfoothefoobarman"
L["foo", "bar"]

You should return the indices: [0,9].
(order does not matter).

 

题目:给定一个字符串S,一个字符串数组L,找出S中所有这样的子串起点,该子串包含L中的所有元素。

说明:

1)L中存在重复的元素
2)子串不允许间断,即子串从开始到找全L中的所有元素之前,子串中不允许包含L以外的东西,而且,即使当前处理的子串是L中含有的,但是前面已经找够了,这个多余的也是不合法的,若此时还有L中的其他元素没找到,从这个起点开始也是不成功的。
3)L在S中出现的顺序不同考虑,任意顺序,只要全部存在就可以。
 

[Leetcode] Substring with Concatenation of All Words

原文:http://www.cnblogs.com/Phoebe815/p/4003278.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!