Common Substring

STRING
DYNAMIC PROGRAMMING

Problem

Given two strings s1 and s2, find the length of the longest common substring. A substring is a contiguous sequence of characters within a string.

Examples

longestCommonFragment('MagicMirrors', 'MirroredMystics') // returns 6 // "Mirror" is the longest echoed fragment longestCommonFragment('EtherealEcho', 'EchoChamber') // returns 4 // "Echo" is the echoed fragment longestCommonFragment('SecretSanctuary', 'SanctumSanctorum') // returns 6 // "Sanctu" is the echoed fragment
Loading...