From 18188cdbb400bef6231e45113ae5c49c542db0a0 Mon Sep 17 00:00:00 2001 From: Yukti Khosla <44090430+Yukti-09@users.noreply.github.com> Date: Tue, 1 Sep 2020 08:05:01 +0530 Subject: [PATCH] Create ArrayPairSum.py --- data_structures/array/ArrayPairSum.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 data_structures/array/ArrayPairSum.py diff --git a/data_structures/array/ArrayPairSum.py b/data_structures/array/ArrayPairSum.py new file mode 100644 index 00000000..d2c76c68 --- /dev/null +++ b/data_structures/array/ArrayPairSum.py @@ -0,0 +1,11 @@ +#Given an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1, b1), (a2, b2), ..., (an, bn) which makes sum of min(ai, bi) for all i from 1 to n as large as possible. + +class Solution: + def arrayPairSum(self, nums: List[int]) -> int: + nums.sort() + x = 0 + i=0 + while(i