Amazon interview question

Follow up on OA2 and time complexity analysis