Meta interview question

Asked leetcode hard Question.