Meta Interview Question

Leetcode question. Difficulty was around a medium