Removing the suffix and prefix substrings which already forms a palindrome and storing them in separate strings
prefix = str . substr ( 0 , len ) ; suffix = str . substr ( n - len ) ; str = str . substr ( len , n - 2 * len ) ;