How to break down a given text into words from the dictionary?

前端 未结 4 1456
一整个雨季
一整个雨季 2021-02-02 15:02

This is an interview question. Suppose you have a string text and a dictionary (a set of strings). How do you break down text into substri

4条回答
  •  野的像风
    2021-02-02 15:21

    There is a very thorough writeup for the solution to this problem in this blog post.

    The basic idea is just to memoize the function you've written and you'll have an O(n^2) time, O(n) space algorithm.

提交回复
热议问题