File tree 2 files changed +14
-0
lines changed
2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change 277
277
[ Meeting Rooms II] ( https://leetcode.com/problems/meeting-rooms-ii/ ) | [ Swift] ( ./Sort/MeetingRoomsII.swift ) | Medium| O(nlogn)| O(n)|
278
278
[ Merge Intervals] ( https://leetcode.com/problems/merge-intervals/ ) | [ Swift] ( ./Sort/MergeIntervals.swift ) | Hard| O(nlogn)| O(n)|
279
279
[ Alien Dictionary] ( https://leetcode.com/problems/alien-dictionary/ ) | [ Swift] ( ./Sort/AlienDictionary.swift ) | Hard| O(nm)| O(nm)|
280
+ [ Array Partition I] ( https://leetcode.com/problems/array-partition-i/description/ ) | [ Swift] ( ./Sort/ArrayPartitionI.swift ) |Easy| O(nlogn)| O(n)|
280
281
281
282
## Union Find
282
283
| Title | Solution | Difficulty | Time | Space |
Original file line number Diff line number Diff line change
1
+ class Solution {
2
+ func arrayPairSum( _ nums: [ Int ] ) -> Int {
3
+ var arr = nums
4
+ arr = arr. sorted { $0 < $1 }
5
+ var res = 0
6
+ for i in 0 ..< arr. count {
7
+ if i & 1 != 0 {
8
+ res += min ( arr [ i] , arr [ i - 1 ] )
9
+ }
10
+ }
11
+ return res
12
+ }
13
+ }
You can’t perform that action at this time.
0 commit comments