Skip to content

Commit 6ac4728

Browse files
authored
Merge pull request #912 from gmoraleda/typo-fix
Typos corrected
2 parents 041c005 + f664af1 commit 6ac4728

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Count Occurrences/README.markdown

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ In code this looks as follows:
2525
func countOccurrences<T: Comparable>(of key: T, in array: [T]) -> Int {
2626
var leftBoundary: Int {
2727
var low = 0
28-
var high = a.count
28+
var high = array.count
2929
while low < high {
3030
let midIndex = low + (high - low)/2
3131
if a[midIndex] < key {
@@ -39,7 +39,7 @@ func countOccurrences<T: Comparable>(of key: T, in array: [T]) -> Int {
3939

4040
var rightBoundary: Int {
4141
var low = 0
42-
var high = a.count
42+
var high = array.count
4343
while low < high {
4444
let midIndex = low + (high - low)/2
4545
if a[midIndex] > key {
@@ -62,7 +62,7 @@ To test this algorithm, copy the code to a playground and then do:
6262
```swift
6363
let a = [ 0, 1, 1, 3, 3, 3, 3, 6, 8, 10, 11, 11 ]
6464

65-
countOccurrencesOfKey(3, inArray: a) // returns 4
65+
countOccurrences(of: 3, in: a) // returns 4
6666
```
6767

6868
> **Remember:** If you use your own array, make sure it is sorted first!

0 commit comments

Comments
 (0)