Meta interview question

2 Leetcode premium exercises. 1 medium and 1 hard