Proposed solution for interview question