Skip to content

Commit

Permalink
[CodeStyle] change for loop statement code style
Browse files Browse the repository at this point in the history
  • Loading branch information
Yi Gu committed Apr 29, 2016
1 parent 53e6521 commit 450e9f3
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Array/ContainsDuplicate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ContainsDuplicate {

var set = Set<Int>()

for i in 0...nums.count - 1 {
for i in 0 ..< nums.count {
if set.contains(nums[i]) {
return true
} else {
Expand Down
2 changes: 1 addition & 1 deletion Array/ContainsDuplicateII.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ContainsDuplicateII {
// key: nums[index], value: index
var dict = [Int: Int]()

for i in 0...nums.count - 1 {
for i in 0 ..< nums.count {
guard let index = dict[nums[i]] where i - index <= k else {
dict[nums[i]] = i
continue
Expand Down
2 changes: 1 addition & 1 deletion Array/RemoveDuplicatesFromSortedArray.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class RemoveDuplicatesFromSortedArray {

var lastIndex = 0

for i in 1...nums.count - 1 {
for i in 1 ..< nums.count {
if nums[i] != nums[lastIndex] {
lastIndex += 1
nums[lastIndex] = nums[i]
Expand Down
2 changes: 1 addition & 1 deletion Array/RemoveDuplicatesFromSortedArrayII.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class RemoveDuplicatesFromSortedArrayII {
}

var lastIndex = 1
for i in 2...nums.count - 1 {
for i in 2 ..< nums.count {
if nums[lastIndex] != nums[i] || nums[lastIndex] != nums[lastIndex - 1] {
lastIndex += 1
nums[lastIndex] = nums[i]
Expand Down
2 changes: 1 addition & 1 deletion Array/RemoveElement.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class RemoveElement {
return lastIndex
}

for i in 0...nums.count - 1 {
for i in 0 ..< nums.count {
if nums[i] != val {
nums[lastIndex] = nums[i]
lastIndex += 1
Expand Down
2 changes: 1 addition & 1 deletion Array/ThreeSum.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ThreeSum {
return res
}

for i in 0...nums.count - 3 {
for i in 0 ... nums.count - 3 {
if i == 0 || nums[i] != nums[i - 1] {
var remain = -nums[i]
var left = i + 1
Expand Down
2 changes: 1 addition & 1 deletion Array/TwoSum.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class TwoSum {
var res = [Int]()
var dict = [Int: Int]()

for i in 0...nums.count - 1 {
for i in 0 ..< nums.count {
guard let lastIndex = dict[target - nums[i]] else {
dict[nums[i]] = i
continue
Expand Down
2 changes: 1 addition & 1 deletion Sort/MeetingRooms.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class MeetingRooms {

var intervals = intervals.sort({$0.start < $1.start})

for i in 0...intervals.count - 2 {
for i in 0 ... intervals.count - 2 {
if intervals[i].end > intervals[i + 1].start {
return false
}
Expand Down
2 changes: 1 addition & 1 deletion Sort/MergeIntervals.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class MergeIntervals {
var res = [Interval]()
res.append(intervals[0])

for i in 1..<intervals.count {
for i in 1 ..< intervals.count {
var last = res[res.count - 1]
var current = intervals[i]
if current.start > last.end {
Expand Down
4 changes: 2 additions & 2 deletions String/CountAndSay.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ class CountAndSay {
var chars: [Character]
var current: Character

for _ in 1..<n{
for _ in 1 ..< n{
temp = ""
count = 1
chars = [Character](res.characters)
current = chars[0]

for i in 1..<chars.count {
for i in 1 ..< chars.count {
if chars[i] == current {
count += 1
} else {
Expand Down

0 comments on commit 450e9f3

Please sign in to comment.