Skip to content

Commit

Permalink
Leetcode question
Browse files Browse the repository at this point in the history
  • Loading branch information
shivamkasaudhan committed Dec 28, 2023
1 parent ea29c10 commit f819569
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions minimumNumberGame.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//2974. Minimum Number Game
//tc nlog(n)
//sc O(1)
//code
class Solution {
public:
vector<int> numberGame(vector<int>& nums) {
sort(nums.begin(),nums.end());
for(int i =0; i<nums.size(); i+=2){
swap(nums[i],nums[i+1]);
}
return nums;
}
};

0 comments on commit f819569

Please sign in to comment.