Smallest Range I
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
You are given an integer array nums and an integer k. For each index i you may apply at most one operation: replace nums[i] with nums[i] + x for any integer x in the range [-k, k].
The score of the array is the difference between its maximum and minimum elements. Return the minimum possible score after applying the operations.
Examples
Constraints
- 1 <= nums.length <= 10^4
- 0 <= nums[i] <= 10^4
- 0 <= k <= 10^4
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.