HackerRank interview question

Easy Medium