Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Count Occurrences/CountOccurrences.playground/Contents.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//: Playground - noun: a place where people can play

func countOccurrencesOfKey(key: Int, inArray a: [Int]) -> Int {
func countOccurrencesOfKey(_ key: Int, inArray a: [Int]) -> Int {
func leftBoundary() -> Int {
var low = 0
var high = a.count
Expand Down Expand Up @@ -53,7 +53,7 @@ func createArray() -> [Int] {
}
}
}
return a.sort(<)
return a.sorted()
}

for _ in 0..<10 {
Expand Down
2 changes: 1 addition & 1 deletion Count Occurrences/CountOccurrences.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Counts the number of times a value appears in an array in O(lg n) time.
The array must be sorted from low to high.
*/
func countOccurrencesOfKey(key: Int, inArray a: [Int]) -> Int {
func countOccurrencesOfKey(_ key: Int, inArray a: [Int]) -> Int {
func leftBoundary() -> Int {
var low = 0
var high = a.count
Expand Down
2 changes: 1 addition & 1 deletion Count Occurrences/README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The trick is to use two binary searches, one to find where the `3`s start (the l
In code this looks as follows:

```swift
func countOccurrencesOfKey(key: Int, inArray a: [Int]) -> Int {
func countOccurrencesOfKey(_ key: Int, inArray a: [Int]) -> Int {
func leftBoundary() -> Int {
var low = 0
var high = a.count
Expand Down