Pregunta de entrevista de SAP

Solve a coding problem. It was on strings again