Driver code
public static void main ( String [ ] args ) { String s = " abcab " ; String ans = longestPrefixSuffix ( s ) ; if ( ans == " " ) System . out . println ( " - 1" ) ; else System . out . println ( ans ) ; } }