F5 Networks Interview Question: largest palindrome in string... | Glassdoor

Interview Question

Senior Software Engineer Interview

largest palindrome in string

Answer

Interview Answer

2 Answers

0

use suffix trees

Interview Candidate on Dec 31, 2011
0

x= "jhjhkvvmadam"
y = []
for i in range(len(x)):
    for j in range(i+1,len(x)):
        if x[i:j+1]==x[i:j+1][::-1]:
            y.append(x[i:j+1])
            print i, j
print y
z = [len(i) for i in y]
print y[z.index(max(z))]

Raviteja Ainampudi on Mar 14, 2017

Add Answers or Comments

To comment on this, Sign In or Sign Up.