WellDev interview question

How did you solve this problem ?