Google interview question

two tasks for an interview, easy-medium