Qualicen Interview Question

Solve the given problem in a live coding session.