We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 38ba0af commit f7a8a64Copy full SHA for f7a8a64
Competitive Coding/Strings/String Search/Manachar_algorithm/manachar_algorithm.py
@@ -1,3 +1,5 @@
1
+''' Given a string, find the longest palindromic substring '''
2
+''' O(n) '''
3
def get_palindrome_length(string, index):
4
length = 1
5
while index + length < len(string) and index - length >= 0:
@@ -13,7 +15,7 @@ def interleave(string):
13
15
ret.extend(['#', s])
14
16
ret.append('#')
17
return ''.join(ret)
-
18
+''' Find longest palindrome number '''
19
def manacher(string):
20
right = 0
21
center = 0
@@ -30,6 +32,6 @@ def manacher(string):
30
32
center = int(i)
31
33
right = center + plength
34
return [e/2 for e in P]
35
+''' Return the palindrome sub-string '''
36
def get_palindrome_number(string):
37
return sum(manacher(string))
0 commit comments