Find shortest subarray with range ≥ k
Company: Meta
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Onsite
Quick Answer: This question evaluates proficiency with array algorithms and range-query reasoning, testing understanding of max/min behavior over contiguous subarrays and use of appropriate data-structure techniques; it belongs to the Coding & Algorithms domain.
Constraints
- Inputs are provided as Python literals matching the function signature.
- Return a deterministic exact-match result.
Examples
Input: ([1,3,2], 2)
Expected Output: 2
Explanation: Prompt example.
Input: ([5,5,5], 1)
Expected Output: -1
Explanation: No qualifying range.
Input: ([4,1,7], 3)
Expected Output: 2
Explanation: Length two qualifies.
Input: ([9], 0)
Expected Output: 1
Explanation: k zero.
Hints
- Choose a representation that makes the core operation simple.
- Handle empty and boundary inputs before the main algorithm.