Skip to content

Commit 17887c3

Browse files
committed
Update readme
1 parent 8e4dbdb commit 17887c3

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Counting Sort/README.markdown

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ Count 0 1 1 1 0 0 0 2 1 1 1
2020
Here is the code to accomplish this:
2121

2222
```swift
23-
let maxElement = array.maxElement() ?? 0
24-
25-
var countArray = [Int](count: Int(maxElement + 1), repeatedValue: 0)
23+
let maxElement = array.max() ?? 0
24+
25+
var countArray = [Int](repeating: 0, count: Int(maxElement + 1))
2626
for element in array {
2727
countArray[element] += 1
2828
}
@@ -62,7 +62,7 @@ Output 1 2 3 7 7 8 9 10
6262
Here is the code for this final step:
6363

6464
```swift
65-
var sortedArray = [Int](count: array.count, repeatedValue: 0)
65+
var sortedArray = [Int](repeating: 0, count: array.count)
6666
for element in array {
6767
countArray[element] -= 1
6868
sortedArray[countArray[element]] = element

0 commit comments

Comments
 (0)