WillowTree interview question

It was a leetcode question.