Pregunta de entrevista de IBM

Two leetcode mediums, pretty reasonable