Skip to content

Commit

Permalink
Time: 187 ms (57.87%), Space: 96.5 MB (94.23%) - LeetHub
Browse files Browse the repository at this point in the history
  • Loading branch information
Dipendra-Raghav committed Nov 17, 2023
1 parent 58ca24e commit 20d0a07
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class Solution {
public:
int minPairSum(vector<int>& nums) {
// priority_queue<int> q;
// for(int i=0;i<nums.size();i++)
// q.push(nums[i]);

sort(nums.begin(),nums.end());
int j=nums.size()-1;
int mn=INT_MIN;
for(int i=0;i<nums.size()/2;i++)
{
int ans = nums[i]+nums[j];
mn=max(mn,ans);
j--;
}
return mn;


}
};

0 comments on commit 20d0a07

Please sign in to comment.