Meta interview question

the leetcode medium coding challenge