Amazon Interview Question

Leetcode easy. Seems i got lucky.