Shortest Palindromic Substring | C ++ program to find the shortest palindromic substring ; Function return the shortest palindromic substring ; Finding the smallest character present in the string ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; char ShortestPalindrome ( string s ) { int n = s . length ( ) ; char ans = s [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { ans = min ( ans , s [ i ] ) ; } return ans ; } int main ( ) { string s = " geeksforgeeks " ; cout << ShortestPalindrome ( s ) ; return 0 ; }