How to find a word from arrays of characters?

前端 未结 4 1445
感动是毒
感动是毒 2020-12-14 04:55

What is the best way to solve this:

I have a group of arrays with 3-4 characters inside each like so:

{p,     {a,    {t,    {m,
 q,      b,     u,            


        
4条回答
  •  渐次进展
    2020-12-14 05:31

    The reformulated question can be answered just by generating and testing. Since you have 4 letters and 10 arrays, you've only got about 1 million possible combinations (10 million if you allow a blank character). You'll need an efficient way to look them up, use a BDB or some sort of disk based hash.

    The trie solution previously posted should work as well, you are just restricted more by what characters you can choose at each step of the search. It should be faster as well.

提交回复
热议问题