The Most Efficient Algorithm to Find First Prefix-Match From a Sorted String Array?

前端 未结 8 724
春和景丽
春和景丽 2021-01-31 00:27

Input:

1) A huge sorted array of string SA;

2) A prefix string P;

Output:

The index of the first string matching the input prefix if any. If ther

8条回答
  •  迷失自我
    2021-01-31 00:47

    It can be done in linear time using a Suffix Tree. Building the suffix tree takes linear time.

提交回复
热议问题