Meta interview question

Leetcode question. Difficulty was around a medium