bugfree Icon
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course

Leetcode Problem 908. Smallest Range I

908. Smallest Range I

Leetcode Solutions

Minimize Score by Adjusting Elements within Range

  1. Find the maximum value in the array, maxVal.
  2. Find the minimum value in the array, minVal.
  3. Calculate the current score as maxVal - minVal.
  4. If the score is less than or equal to 2 * k, return 0, as we can make all elements equal.
  5. Otherwise, return the score reduced by 2 * k, which is maxVal - minVal - 2 * k.
UML Thumbnail

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...