Levenshtein Distance Algorithm better than O(n*m)?

前端 未结 4 648
说谎
说谎 2020-11-28 22:49

I have been looking for an advanced levenshtein distance algorithm, and the best I have found so far is O(n*m) where n and m are the lengths of the two strings. The reason w

4条回答
  •  孤独总比滥情好
    2020-11-28 23:15

    Look in Wiki - they have some ideas to improve this algorithm to better space complexity:

    Wiki-Link: Levenshtein distance

    Quoting:

    We can adapt the algorithm to use less space, O(m) instead of O(mn), since it only requires that the previous row and current row be stored at any one time.

提交回复
热议问题