Three-Part Partition with Minimum Largest Range
Updated
Problem statement
Split nums into exactly three nonempty contiguous parts, preserving the array order. Choose two cut positions so that every element belongs to one part.
The range of a part is its maximum element minus its minimum element. A one-element part has range zero.
Return the minimum possible value of the largest range among the three parts.
Function
minimumLargestRange(nums: int[]) → intExamples
Example 1
nums = [1,2,3,10,11,20]return = 2The parts [1,2,3], [10,11] and [20] have ranges 2, 1 and 0. A bound of 1 needs more than three parts.
Example 2
nums = [1,100,2,101,3]return = 98The parts [1], [100,2] and [101,3] have ranges 0, 98 and 98. A bound below 98 requires at least four parts.
Example 3
nums = [-9,0,9]return = 0Each of the three elements can be its own part, giving three zero ranges.
Constraints
- 3 <= nums.length <= 100000.
- -1000000000 <= nums[i] <= 1000000000.
More LSEG Online Assessment questions
- Count Times Using at Most Two DigitsOA · Seen Jul 2025
- Maximum Sum of Exactly Three Non-Adjacent ElementsOA · Seen Jul 2025
- Maximum Word Count in a SentenceOA · Seen Jul 2025
- Minimum Digit Swaps for the Smallest DifferenceOA · Seen Jul 2025
- Smallest String After at Most One DeletionOA · Seen Jul 2025
- Delete One Digit 5 to Maximize the NumberOA · Seen Feb 2025
- Transform a String with at Most One OperationOA · Seen Feb 2025
- Price Equity Options and ForwardsOA · Seen Dec 2024
- Maximum Sum of Non-Adjacent ElementsOA · Seen Sep 2024
- Return the Sentence with the Most WordsOA · Seen Sep 2024
Similar questions at other companies
- Capacity to Ship Packages Within DaysMicrosoft · OA · ONSITE INTERVIEWMicrosoft interview questions
- Rock JumpingIMC Trading · OAIMC Trading interview questions
- Minimum Robot and Human Fulfillment TimeAmazon · OA
- Minimize Maximum Group DifferenceDRW · OADRW interview questions
- Array NullificationQRT · OA
- Minimum-Cost Solar Rooftop AllocationDeloitte · OADeloitte interview questions
- K-Means ClusteringAtlassian · OAAtlassian interview questions
- Get Minimum Development TimeSalesforce · OASalesforce interview questions
- Job ExecutionMathWorks · OAMathWorks interview questions
- Police Station 🚓The D.E. Shaw Group · OAThe D.E. Shaw Group interview questions