Amazon interview question

two algorithm s are about the string