Minimize Range After Three Changes
Updated
Problem statement
You are given an integer array nums. You may change the value of at most three elements to any integers.
Return the minimum possible difference between the largest and smallest values after the changes.
Function
minimizeRange(nums: int[]) → intExamples
Example 1
nums = [5,3,2,4]return = 0Change three values to match the remaining value, so the range becomes 0.
Example 2
nums = [1,5,6,14,15]return = 1Keep 5 and 6 and change the other three elements.
Example 3
nums = [6,6,0,1,1,4,6]return = 2Changing 0, both 1s, or an equivalent set leaves values between 4 and 6.
Constraints
1 <= nums.length <= 100000-1000000000 <= nums[i] <= 1000000000
More DRW interview questions
- Defer Expenses to Preserve BalancePHONE SCREEN · Seen Oct 2026
- Longest Equal-Frequency SubstringPHONE SCREEN · Seen Oct 2026
- Count Balanced Nodes in a Rooted TreeOA · Seen Sep 2026
- Largest Number With Even Digit FrequenciesOA · Seen Sep 2026
- Shortest Path Around Rectangular ObstaclesOA · Seen Sep 2026
- 2020 Account Balance with Monthly Card FeesOA · Seen Aug 2026
- Nested In-Memory Database TransactionsOA · Seen Aug 2026
- Password Requirement CheckOA · Seen Aug 2026
- Remove Excess Consecutive CharactersOA · Seen Aug 2026
- Last Round for Each PlayerOA · Seen Jul 2026
Similar questions at other companies
- Fair Capped Money DistributionGusto · PHONE SCREEN · ONSITE INTERVIEWGusto interview questions
- Tennis Court SchedulingAtlassian · PHONE SCREEN · ONSITE INTERVIEWAtlassian interview questions
- Maximum Number of Events That Can Be AttendedByteDance · PHONE SCREENByteDance interview questions
- Remove the Fewest Magic BeansThe D.E. Shaw Group · PHONE SCREENThe D.E. Shaw Group interview questions
- Aggressive CowsAmazon · PHONE SCREEN
- Maximize Workday EarningsCitadel · OA · PHONE SCREEN · ONSITE INTERVIEWCitadel interview questions
- Experiment Bucket Allocation and RebalancingPinterest · PHONE SCREENPinterest interview questions
- Maximum Number of Events That Can Be AttendedSnowflake · PHONE SCREENSnowflake interview questions
- Minimum Appointment Cancellations with a Required BreakMaven Clinic · PHONE SCREENMaven Clinic interview questions
- Two City Scheduling with an Odd Candidate CountBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions