Блог пользователя cardcounter

Автор cardcounter, история, 4 часа назад, По-английски

What is an efficient algorithm for regex search all occurrences (starting indexes) of a pattern in a long string?

Say I only have special character * in this question, which matches zero or any numbers of the preceeding characters: https://leetcode.com/problems/regular-expression-matching/

a* search in aaa returns [0, 1, 2]

a*b search in abb returns [0]

Here a* and a*b are patterns and aaa and abb are text strings to search within and text strings could be very long.

Borrowing https://leetcode.com/problems/regular-expression-matching/ I can only come up with a solution with O(N * N * M)

References:

https://mirror.codeforces.com/blog/entry/73568

https://mirror.codeforces.com/blog/entry/111380

  • Проголосовать: нравится
  • -6
  • Проголосовать: не нравится

»
4 часа назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by cardcounter (previous revision, new revision, compare).

»
4 часа назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by cardcounter (previous revision, new revision, compare).