Amazon Interview Question

Straight forward from geeksforgeeks