Monday, July 25, 2016

substring - facebook code lab - Leetcode 30

July 25, 2016

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.
Example :
S: "barfoothefoobarman"
L: ["foo", "bar"]
You should return the indices: [0,9].
(order does not matter).

Plan to work on the problem

Get Java, C++ code:

1. C++ solution: 
study C++ code:
https://gist.github.com/jianminchen/1eb3d40f6173f07c7db90d39c1c71edf

from blog:
https://yujia.io/blog/2015/11/17/LeetCode-30-Substring-with-Concatenation-of-All-Words/

2. sliding windows method - introduction - great idea - ... 
study Java code:
https://gist.github.com/jianminchen/c1f4d4f0b53cd197e3cfaa968a76f62e

from the blog:  http://yuanhsh.iteye.com/blog/2187543

Review sliding window blog:
http://juliachencoding.blogspot.ca/2015/07/leetcode-longest-substring-without.html

No comments:

Post a Comment