Reverse the remaining String to find the palindromic suffix
rem_str = reverse ( rem_str ) ; let suff_of_rem_str = palindromePrefix ( rem_str ) ; if ( pre_of_rem_str . length >= suff_of_rem_str . length ) { return pre + pre_of_rem_str + suff ; } else { return pre + suff_of_rem_str + suff ; } } function reverse ( input ) { let a = input . split ( ' ' ) ; let l , r = a . length - 1 ; for ( l = 0 ; l < r ; l ++ , r -- ) { let temp = a [ l ] ; a [ l ] = a [ r ] ; a [ r ] = temp ; } return parseInt ( a ) ; }