Shortest Palindromic Substring | Java program to find the shortest palindromic subString ; Function return the shortest palindromic subString ; Finding the smallest character present in the String ; Driver code
class GFG { static char ShortestPalindrome ( String s ) { int n = s . length ( ) ; char ans = s . charAt ( 0 ) ; for ( int i = 1 ; i < n ; i ++ ) { ans = ( char ) Math . min ( ans , s . charAt ( i ) ) ; } return ans ; } public static void main ( String [ ] args ) { String s = " geeksforgeeks " ; System . out . print ( ShortestPalindrome ( s ) ) ; } }