In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
In this issue, the editor will bring you about how to split arrays in leetcode. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.
I. the content of the topic
Given an integer array nums of length 2n, your task is to divide these numbers into n pairs, such as (A1, b1), (a2, b2),..., (an, bn), so that the sum of min (ai, bi) from 1 to n is maximum.
Returns the maximum sum.
Example 1:
Input: nums = [1, 4, 3, 2]
Output: 4
Explanation: all possible divisions (ignoring the order of elements) are:
1. (1,4), (2,3)-> min (1,4) + min (2,3) = 1 + 2 = 3
2. (1,3), (2,4)-> min (1,3) + min (2,4) = 1 + 2 = 3
3. (1,2), (3,4)-> min (1,2) + min (3,4) = 1 + 3 = 4
So the maximum sum is 4.
Example 2:
Input: nums = [6, 2, 6, 5, 1, 2]
Output: 9
Explanation: the optimal method is (2, 1), (2, 5), (6, 6). Min (2,1) + min (2,5) + min (6,6) = 1 + 2 + 6 = 9
Tip:
one
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.