Meta interview question

Leetcode hard and some variants on the same