Strings Problem

Правка en1, от jigsaw7, 2019-08-18 04:50:43

Given 2 strings S1 and S2 consisting of English letters.
For each index i in S1, it is required to find the largest index j >= i such that S1[i..j] is a substring of S2.

For example,
S1 = "acdsuaf"
S2 = "cadsua"
ans = [1, 2, 6, 6, 6, 6, -1].

How to approach this problem in linear time?

Теги #strings

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский jigsaw7 2019-08-18 04:50:43 373 Initial revision (published)