Lexicographically all Shortest Palindromic Substrings from a given string | C ++ 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
#include <bits/stdc++.h> NEW_LINE using namespace std ; void shortestPalindrome ( string s ) { int abcd [ 26 ] = { 0 } ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) abcd [ s [ i ] - 97 ] = 1 ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( abcd [ i ] == 1 ) cout << char ( i + 97 ) << " ▁ " ; } } int main ( ) { string s = " geeksforgeeks " ; shortestPalindrome ( s ) ; return 0 ; }