Substring with Concatenation of All Words
来源:互联网 发布:centos 6.5配置hadoop 编辑:程序博客网 时间:2024/05/16 09:23
Substring with Concatenation of All Words
You are given a string, s, and a list of words, words, that are all of the same length. Find all starting indices of substring(s) in s that is a concatenation of each word in wordsexactly once and without any intervening characters.
For example, given:
s: "barfoothefoobarman"
words: ["foo", "bar"]
You should return the indices: [0,9]
.
(order does not matter).
但是这个题tricky一点在于要发现,只要遍历 string 每个单词长度(K) 遍 就可以包含全部情况。
几个容易出错的地方在代码中有标注。
这题是要求 without intervening characters的。这里跟 Minimum Window Substring 要求不同。所以就导致了再一次遍历中存在着重新初始化的情况(map初始化)
这一点应该是可以提升的,毕竟每次遇见intervening string就重启一个大的map很耗时。如果可以只修复map被污染的部分会好些。
0 0
- LeetCode: Substring with Concatenation of All Words
- LeetCode : Substring with Concatenation of All Words
- LeetCode29: Substring with Concatenation of All Words
- [Leetcode] Substring with Concatenation of All Words
- Substring with Concatenation of All Words
- Substring with Concatenation of All Words
- [LeetCode]Substring with Concatenation of All Words
- Substring with Concatenation of All Words
- LeetCode-Substring with Concatenation of All Words
- [LeetCode] Substring with Concatenation of All Words
- 26 - Substring with Concatenation of All Words
- LeetCode:Substring with Concatenation of All Words
- Leetcode: Substring with Concatenation of All Words
- [LeetCode] Substring with Concatenation of All Words
- leetcode Substring with Concatenation of All Words
- leetcode Substring with Concatenation of All Words
- Substring with Concatenation of All Words
- LeetCode Substring with Concatenation of All Words
- Linux程序make过程中库文件缺失:cannot find -lixxx && fatal error: xxx.h: No such file or directory 解决方法参考
- 第4章 控制执行流程
- windows Loader激活调用程序
- FreeMarker主题
- fragment 加入返回栈失效
- Substring with Concatenation of All Words
- Java网络编程
- ps与pstree小结
- jQuery 发送 post 请求返回字符串乱码的解决
- ajax+mysql
- java中this关键字的用法
- hdoj 1000
- hdoj 1001
- VMware中桥接(Bridged)模式静态ip的CentOS配置