Meta interview question

two leetcode style algorithm questions