Practice/Meta/Leetcode 163. Missing Ranges
CodingMust
You are given a sorted array of unique integers nums and two integers lower and upper that define an inclusive range. Your task is to identify all numbers and continuous ranges that fall within [lower, upper] but are missing from the array.
Return a list of strings where each string represents either:
"x""a->b"The returned list should be in ascending order.
nums is sorted in ascending order and contains distinct integers[lower, upper]"5")"start->end" (e.g., "10->15")nums are distinctnums is sorted in ascending orderExample 1:
` Input: nums = [0, 1, 3, 50, 75], lower = 0, upper = 99 Output: ["2", "4->49", "51->74", "76->99"] Explanation:
Example 2:
Input: nums = [], lower = 1, upper = 1 Output: ["1"] Explanation: The entire range contains just one number and it's missing
Example 3:
Input: nums = [1, 2, 3, 4, 5], lower = 1, upper = 5 Output: [] Explanation: All numbers in the range are present
Example 4:
Input: nums = [10, 20], lower = 5, upper = 25 Output: ["5->9", "11->19", "21->25"] Explanation: Missing ranges appear before, between, and after the array elements