Array Partition Problem
Array Partition Problem — ExecCode Easy DSA Practice
Solve the Array Partition problem on ExecCode. Free online easy DSA practice in Arrays - Logic Building. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Description You are given an integer array nums of 2n integers, group these integers into n pairs (a1, b1), (a2, b2), ..., (an, bn) such that the sum of min(ai, bi) for all i is maximized. Your task is to compute the required answer and return the maximized sum.
Examples
Input {"nums": [1, 4, 3, 2]}; Output 4. Input {"nums": [6, 2, 6, 5, 1, 2]}; Output 9
Constraints
1 <= n <= 10^4 nums.length == 2 * n -10^4 <= nums[i] <= 10^4
Practice Array Partition free on ExecCode. Browse DSA problems, topic map, and placement guides.