Amazon Interview Question

Follow up on OA2 and time complexity analysis