Solution to Substring with Concatenation of All Words by LeetCode

26 Apr

Question: http://oj.leetcode.com/problems/substring-with-concatenation-of-all-words/

Question Name: Substring with Concatenation of All Words

The brute force method works here. Assume the hash function is O(n). Let the length of S be M, the length of L be N, and the length of each word in L be P, as intruduced in other solutions, the worst time complexity O(M*N*P) is accepted by the OJ system. It could be optimized by using Caterpillar method. The following optimization solution need O(M*P).

Leave a Reply

Your email address will not be published. Required fields are marked *

Please put your code into a <pre>YOUR CODE</pre> section. Thanks and Happy Coding!