Qualicen interview question

Solve the given problem in a live coding session.