Content deleted Content added
m Fixing links to disambiguation pages, replaced: graphs{{dn|date=January 2016}} → graphs using AWB |
Fixed an error in the algorithm so that sj begins with the 1st character, not the 0th. Also clarified an if statement since one of it's arguments is always true if the other is true. |
||
Line 42:
f = [-1] * len(S) # Failure function
k = 0 # Least rotation of string found so far
for j
sj = S[j]
i = f[j-k-1]
while i != -1 and sj != S[k+i+1]:
Line 48 ⟶ 49:
k = j-i-1
i = f[i]
if
if sj < S[k]: # k+i+1
k = j
f[j-k] = -1
|