Pregunta de entrevista de SAP

leetcode question (i think it was a leetcode easy)