Meta Interview Question

Basic algorithm question, leetcode medium