Google interview question

2 leetcode questions, one easy one hard