Lexicographically all Shortest Palindromic Substrings from a given string | Java program to find 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
class Main { static void shortestPalindrome ( String s ) { int [ ] abcd = new int [ 26 ] ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) abcd [ s . charAt ( i ) - 97 ] = 1 ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( abcd [ i ] == 1 ) { System . out . print ( ( char ) ( i + 97 ) + " ▁ " ) ; } } } public static void main ( String [ ] args ) { String s = " geeksforgeeks " ; shortestPalindrome ( s ) ; } }