Palindromic Substrings Problem Statement

Given a string S, your task is to return all distinct palindromic substrings of the given string in alphabetical order.

Explanation:

A string is considered a palindrome if the reverse of the string is the same as the string itself.

Example:

Input:
S = 'abba'
Output:
'a' 'abba' 'b' 'bb'
Explanation:

All possible substrings of 'abba' are ['a', 'ab', 'abb', 'abba', 'b', 'ba', 'bb', 'bba'], out of which ['a', 'abba', 'b', 'bb'] are palindromic substrings.

Constraints:

  • 1 <= T <= 10
  • 1 <= |S| <= 1000
  • String S contains lowercase English letters only.
  • Time limit: 1 sec
Note:

You do not need to print anything. It has already been taken care of. Just implement the given function.

AnswerBot
1d

Return all distinct palindromic substrings of a given string in alphabetical order.

  • Iterate through all possible substrings of the given string.

  • Check if each substring is a palindrome.

  • Store distinct pa...read more

Help your peers!
Add answer anonymously...
Amdocs Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter