Tesla interview question

given two coderpad questions to solve in 30 min