In an Alten Nederland mobile app telemetry pipeline, event IDs should be unique within a single upload batch. Given a list of integers event_ids, return the first value that appears more than once when scanning from left to right. If no duplicate exists, return -1.
event_ids, a list of integers-1 if all values are uniqueA value is considered the first duplicate if its second occurrence appears before the second occurrence of any other duplicated value.
Example 1
event_ids = [4, 7, 1, 7, 3, 1]77 is the first value whose second occurrence is encountered.Example 2
event_ids = [2, 5, 6, 8]-11 <= len(event_ids) <= 10^5-10^9 <= event_ids[i] <= 10^9After implementing the function, discuss the time complexity of your solution and why it is better than checking every pair.