Mindrift interview question

Two basic HackerRank problems. 1h30mins given but they could be completed in 20 minutes.