五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

LeetCode 2740. Find the Value of the Partition

2023-06-18 12:24 作者:您是打尖兒還是住店呢  | 我要投稿

You are given a?positive?integer array?nums.

Partition?nums?into two arrays,?nums1?and?nums2, such that:

  • Each element of the array?nums?belongs to either the array?nums1?or the array?nums2.

  • 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 array?nums1, and?min(nums2)?denotes the minimum element of the array?nums2.

Return?the integer denoting the value of such partition.

?

Example 1:

Input: nums = [1,3,2,4]Output: 1Explanation: We can partition the array nums into nums1 = [1,2] and nums2 = [3,4]. - The maximum element of the array nums1 is equal to 2. - The minimum element of the array nums2 is equal to 3. The value of the partition is |2 - 3| = 1. It can be proven that 1 is the minimum value out of all partitions.

Example 2:

Input: nums = [100,1,10]Output: 9Explanation: We can partition the array nums into nums1 = [10] and nums2 = [100,1]. - The maximum element of the array nums1 is equal to 10. - The minimum element of the array nums2 is equal to 1. The value of the partition is |10 - 1| = 9. It can be proven that 9 is the minimum value out of all partitions.

?

Constraints:

  • 2 <= nums.length <= 105

  • 1 <= nums[i] <= 109

排序,計(jì)算每2個(gè)相鄰的差值,最小的即可返回;

Runtime:?22 ms, faster than?100.00%?of?Java?online submissions for?Find the Value of the Partition.

Memory Usage:?54.5 MB, less than?80.00%?of?Java?online submissions for?Find the Value of the Partition.


LeetCode 2740. Find the Value of the Partition的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
屏东县| 平凉市| 砀山县| 绥江县| 濮阳县| 屏山县| 攀枝花市| 奉新县| 同心县| 定日县| 北海市| 灌南县| 宿迁市| 连平县| 湾仔区| 阜平县| 稻城县| 溆浦县| 新野县| 荣成市| 滕州市| 彭山县| 襄城县| 永康市| 佛冈县| 盐池县| 临安市| 新昌县| 永泰县| 林口县| 阿城市| 锡林郭勒盟| 栾川县| 北辰区| 江津市| 固阳县| 大埔县| 中超| 平舆县| 新竹县| 延边|