IBM Interview Question

Two leetcode mediums, pretty reasonable