Meta interview question

two leetcode style questions, one easy one medium.