开发者

Longest common substring with constant memory?

开发者 https://www.devze.com 2022-12-08 13:54 出处:网络
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 s

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

0

精彩评论

暂无评论...
验证码 换一张
取 消