Problem of the day
Input: ‘S’ =’badam’
Output: ‘ada’
‘ada’ is the longest palindromic substring, and it can be proved that it is the longest possible palindromic substring.
First-line contains 'T', denoting the number of Test cases.
For each Test case:
The first line contains an integer ‘N’ denoting the string ‘S’ length.
The second line contains the string ‘S’, consisting of lowercase English alphabets.
Return the longest palindromic substring in ‘S’.
You don't need to print anything. Just implement the given function.
1 <= 'T' <= 10
1 <= 'N' <= 10^5
‘a’ <= ‘S[i]’ <= ‘Z’
Time Limit: 1 sec
2
6
adccdb
6
aaabbb
dccd
aaa
For test case 1:
‘S’ =’adccdb’
‘dccd’ is the longest palindromic substring, and it can be proved that it is the longest possible palindromic substring.
Hence we return ‘dccd’.
For test case 2:
‘S’ =’aaabbb’
‘aaa’ is the longest palindromic substring, and it can be proved that it is the longest possible palindromic substring.
Hence we return ‘dccd’.
‘Bbb’ is also a valid answer.
2
5
hello
1
a
ll
a