Pergunta de entrevista da empresa IBM

Two leetcode mediums, pretty reasonable