Meta interview question

Code interview from leet code