Lexicographically all Shortest Palindromic Substrings from a given string | Function to find all lexicographically shortest palindromic substring ; Array to keep track of alphabetic characters ; Iterate to print all lexicographically shortest substring ; Driver code
def shortestPalindrome ( s ) : NEW_LINE INDENT abcd = [ 0 ] * 26 NEW_LINE for i in range ( len ( s ) ) : NEW_LINE INDENT abcd [ ord ( s [ i ] ) - 97 ] = 1 NEW_LINE DEDENT for i in range ( 26 ) : NEW_LINE INDENT if abcd [ i ] == 1 : NEW_LINE INDENT print ( chr ( i + 97 ) , end = ' ▁ ' ) NEW_LINE DEDENT DEDENT DEDENT s = " geeksforgeeks " NEW_LINE shortestPalindrome ( s ) NEW_LINE