Meta Interview Question

Leetcode medium difficulty question with slight modification