← 返回 amazon 的题目列表Find the Closest Version by Release Date
类型:online_judge
Problem: Find the Closest Version by Release Date
Given a target version date target and a list of version release dates versions, return the release date closest to target.
All dates are in YYYY-MM-DD format.
“Closest” means the minimum absolute difference in days from the target date.
If multiple dates have the same distance, return the earlier date.
The input list may be unsorted.
Input Format
n
target
version_1
version_2
...
version_n
Output Format
closest_version_date
Constraints
1 <= n <= 200000
All dates are valid Gregorian dates with years in [0001, 9999].
Example
Input:
3
2026-04-01
2023-04-01
2025-04-01
2026-05-03
Output:
2026-05-03
Example
Input
3
2026-04-01
2023-04-01
2025-04-01
2026-05-03
Output
2026-05-03