Search for strings matching the pattern “abc:*:xyz” in less than O(n)

前端 未结 4 1043
有刺的猬
有刺的猬 2021-01-07 10:45

Given a bunch of strings I need to find those which match 3 kinds of patterns:

  • Prefix search - abc*
  • Glob-like pattern - abc:*:xyz
  • Suffix sear
4条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-07 11:20

    Wouldn't an intersection of the results from the other two queries give you exactly that? And since each of the results is O(log N) and an intersect over that result set is O(N) in the result-set size, wouldn't the total also be an O(log N) over the original problem?

提交回复
热议问题