Amazon Interview Question

What if there are some boundary cases?