Skip to content

Commit f7a8a64

Browse files
Update manachar_algorithm.py
1 parent 38ba0af commit f7a8a64

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Competitive Coding/Strings/String Search/Manachar_algorithm/manachar_algorithm.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
''' Given a string, find the longest palindromic substring '''
2+
''' O(n) '''
13
def get_palindrome_length(string, index):
24
length = 1
35
while index + length < len(string) and index - length >= 0:
@@ -13,7 +15,7 @@ def interleave(string):
1315
ret.extend(['#', s])
1416
ret.append('#')
1517
return ''.join(ret)
16-
18+
''' Find longest palindrome number '''
1719
def manacher(string):
1820
right = 0
1921
center = 0
@@ -30,6 +32,6 @@ def manacher(string):
3032
center = int(i)
3133
right = center + plength
3234
return [e/2 for e in P]
33-
35+
''' Return the palindrome sub-string '''
3436
def get_palindrome_number(string):
3537
return sum(manacher(string))

0 commit comments

Comments
 (0)