Domanda di colloquio di OpenText

Two coding round question asked. Basic problem