Meta Interview Question

Leetcode Hard.