WillowTree Interview Question

It was a leetcode question.