2740. Find the Value of the Partition
You are given a positive integer array
nums.Partition
numsinto two arrays,nums1andnums2, such that:
- Each element of the array
numsbelongs to either the arraynums1or the arraynums2.- Both arrays are non-empty.
- The value of the partition is minimized.
The value of the partition is
|max(nums1) - min(nums2)|.Here,
max(nums1)denotes the maximum element of the arraynums1, andmin(nums2)denotes the minimum element of the arraynums2.Return the integer denoting the value of such partition.
1 | class Solution { |