Shawn's Blog

  • Home
  • Tags
  • Categories
  • Archives
  • Search
  • Table of Contents
  • Overview

Shawn

若有恒,何必三更眠五更起;最无益,莫过一日曝十日寒。
392 posts
13 categories
114 tags

LeetCode 561. Array Partition I

Posted on 2021-02-16 Edited on 2024-11-24 In LeetCode
1
2
3
4
5
6
7
8
9
10
class Solution {
public:
int arrayPairSum(vector<int>& nums) {
sort(nums.begin(), nums.end());
int n = nums.size(), ans = 0;
for (int i = 0; i < n; i += 2)
ans += nums[i];
return ans;
}
};
# Array
LeetCode 395. Longest Substring with At Least K Repeating Characters
LeetCode 566. Reshape the Matrix
© 2024 Shawn
Powered by Hexo & NexT.Mist
0%