Amazon Interview Question

Two algorithm problems average medium difficulty