Caseware interview question

Leet code medium to easy. not hard problems