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 solution.
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 solution.
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...