Skip to content

Commit 813b46e

Browse files
committedAug 13, 2017
Fix code style about for loop and sorted by func
1 parent c0e09ca commit 813b46e

File tree

98 files changed

+193
-193
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+193
-193
lines changed
 

‎Array/ContainsDuplicateII.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class ContainsDuplicateII {
1616
// key: nums[index], value: index
1717
var dict = [Int: Int]()
1818

19-
for i in 0 ..< nums.count {
19+
for i in 0..<nums.count {
2020
guard let index = dict[nums[i]] where i - index <= k else {
2121
dict[nums[i]] = i
2222
continue

‎Array/FourSum.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
*/
77

88
class FourSum {
9-
func fourSum(nums: [Int], _ target: Int) -> [[Int]] {
10-
let nums = nums.sort({$0 < $1})
9+
func fourSum(_ nums: [Int], _ target: Int) -> [[Int]] {
10+
let nums = nums.sorted(by: <)
1111
var threeSum = 0
1212
var twoSum = 0
1313
var left = 0
@@ -18,13 +18,13 @@ class FourSum {
1818
return res
1919
}
2020

21-
for i in 0 ..< nums.count - 3 {
21+
for i in 0..<nums.count - 3 {
2222
guard i == 0 || nums[i] != nums[i - 1] else {
2323
continue
2424
}
2525
threeSum = target - nums[i]
2626

27-
for j in i + 1 ..< nums.count - 2 {
27+
for j in i + 1..<nums.count - 2 {
2828
guard j == i + 1 || nums[j] != nums[j - 1] else {
2929
continue
3030
}

0 commit comments

Comments
 (0)
Please sign in to comment.