forked from computiq/GIZ-pass-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython-pass.py
More file actions
27 lines (23 loc) · 774 Bytes
/
python-pass.py
File metadata and controls
27 lines (23 loc) · 774 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
class Solution:
@staticmethod
def longest_palindromic(s: str) -> str:
def longest_palindromic(s: str) -> str:
res = ""
if len(s) == 1:
print(s)
else:
for v in range(1, len(s)):
if s == s[::-1]:
if len(s) >= len(res):
res = s
break
else:
for i in range(1, len(s)):
subString = s[i:]
if subString == subString[::-1]:
if len(subString) >= len(res):
res = subString
break
s = s[:-v]
print(res)
Solution.longest_palindromic(s="babad")