RedDoorz Interview Question

How to solve this problem?