klgraham / longest-common-substring

An implementation of the longest common substring algorithm in Swift.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Longest Common Substring

The longest common substring problem is where you want to find the longest string that is a substring of two other strings. For example, the longest common substring of "encyclopedia" and "encyclical" is "ncycl".

This repo contains implementations of the longest common substring algorithm in Swift. There's an implementation based on suffix arrays and a dynamic programming implementation. The suffix array implementation is largely ported from Robert Sedgewick and Kevin Wayne's textbook Algorithms, 4th edition. The suffix array algorithm should run in O(m + n) time, while the dynamic programming version should run in O(mn) time, where m and n are the lengths of the input strings.

About

An implementation of the longest common substring algorithm in Swift.

License:MIT License


Languages

Language:Swift 100.0%