
In a Google Photos mobile client, event timestamps may arrive unsorted after local batching. Given an integer array timestamps and an integer target, return the index of the first occurrence of target after sorting the array in non-decreasing order. If target does not exist, return -1.
timestamps is a list of integers. target is an integer.target in the sorted version of timestamps, or -1 if not found.Example 1
timestamps = [8, 3, 5, 3, 10], target = 30[3, 3, 5, 8, 10]. The first 3 is at index 0.Example 2
timestamps = [12, 7, 9, 1], target = 8-1[1, 7, 9, 12]. The value 8 is not present.1 <= len(timestamps) <= 10^5-10^9 <= timestamps[i] <= 10^9-10^9 <= target <= 10^9O(log n) after sorting.timestamps = [8, 3, 5, 3, 10], target = 3Output0WhyAfter sorting, the array is `[3, 3, 5, 8, 10]`, and the first occurrence of `3` is at index `0`.timestamps = [12, 7, 9, 1], target = 8Output-1WhyAfter sorting, the array is `[1, 7, 9, 12]`. Since `8` is not present, return `-1`.timestamps = [4, 4, 4, 4], target = 4Output0WhyAll elements are equal to the target, so the first occurrence is the first index.1 <= len(timestamps) <= 10^5-10^9 <= timestamps[i] <= 10^9-10^9 <= target <= 10^9Search should be performed with binary search after sortingdef first_sorted_occurrence(timestamps, target):