Longest common substring with constant memory?
Given two strings -- how can you find the longest common substring using only constant memory?
UPDATE: The time constraints are to solve it in O(len1 * len2), like the standard dynamic-programming solu开发者_如何学Ction.
Constant memory and no time constraints?
Just do a brute force approach: compare all possibilities, keeping just 6 integer indexes in memory: start
and end
for both strings, plus 2 for the longest string found yet...
精彩评论