Meta interview question

Leetcode