Skip to content

Commit 1f4eb22

Browse files
committed
2974. Minimum Number Game
1 parent cfe6316 commit 1f4eb22

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution {
2+
3+
// Solution by Sergey Leschev
4+
// 2974. Minimum Number Game
5+
6+
func numberGame(_ nums: [Int]) -> [Int] {
7+
var sortedNums = nums.sorted()
8+
var arr = [Int]()
9+
10+
for i in stride(from: 1, to: sortedNums.count, by: 2) {
11+
sortedNums.swapAt(i, i - 1)
12+
}
13+
14+
arr.append(contentsOf: sortedNums)
15+
return arr
16+
}
17+
}

0 commit comments

Comments
 (0)