Meta Interview Question

leetcode hard question