Given a sorted array nums and an integer target, return the element in nums that is closest to target. If two elements are equidistant from target, return the smaller one.
Input: A sorted integer array nums and integer target.
Output: The element in nums closest to target.
Input: [1,3,5,7,9], 4
Output: 3
Explanation: |3-4|=1, |5-4|=1 → tie → return smaller = 3.Input: [1,3,5,7,9], 6
Output: 5
Explanation: |5-6|=1 < |7-6|=1 → tie... actually |5-6|=1 and |7-6|=1, return smaller=5.Input: [1,3,5,7,9], 0
Output: 1
Explanation: 1 is smallest and closest to 0.1 <= nums.length <= 10^4-10^4 <= nums[i] <= 10^4Sorted ascendingAll distinct