Find missing ranges in interval
MetaSoftware Engineer · OnsiteLast updated
This question evaluates a candidate's proficiency in array traversal, interval reasoning, handling edge cases including empty inputs and 32-bit integer boundary conditions, and enforcing time and space complexity constraints.
Given a sorted unique integer array nums and two integers lower and upper defining an inclusive interval [lower, upper], return all missing ranges not present in nums within this interval. Format each missing range as "a" for single numbers or "a->b" for ranges. Consider cases where nums is empty, elements fall outside [lower, upper], or boundaries approach 32-bit integer limits. Aim for O(n) time and O(
- extra space (excluding output).
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.