FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
pythonprogram/longestPalindrome at master · Spacecoder19/pythonprogram · GitHub
Spacecoder19
pythonprogram
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
pythonprogram
/
longestPalindrome
Copy path
More file actions
More file actions
Latest commit
History
History
History
22 lines (22 loc) · 502 Bytes
Breadcrumbs
pythonprogram
/
longestPalindrome
Copy path
File metadata and controls
22 lines (22 loc) · 502 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
t= int(input())
for k in range(t):
str=input()
substring=[]
for i in range(len(str)):
for j in range(i+1,len(str)+1):
substring.append(str[i:j])
pal=[]
for i in range(0,len(substring)):
temp=substring[i]
temp1=temp[::-1]
if (temp==temp1):
pal.append(temp)
max=""
for i in range(0,len(pal)):
if((len(pal[i])>len(max)) and (len(pal[i])>1)):
max=pal[i]
elif(len(max)<=1):
max=pal[0] #max=str[:1]
print(max)
substring.clear()
pal.clear()
Back
|
FazBrowse Home
|
New Git URL