OpenText interview question

Two coding round question asked. Basic problem