Skip to content

Commit c014bd9

Browse files
remove "countingSort" func throws
if you received empty array, just return empty array
1 parent 90730ad commit c014bd9

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

Counting Sort/CountingSort.swift

+2-8
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,8 @@
66
// Copyright © 2016 Ali Hafizji. All rights reserved.
77
//
88

9-
enum CountingSortError: Error {
10-
case arrayEmpty
11-
}
12-
13-
func countingSort(_ array: [Int]) throws -> [Int] {
14-
guard array.count > 0 else {
15-
throw CountingSortError.arrayEmpty
16-
}
9+
func countingSort(_ array: [Int])-> [Int] {
10+
guard array.count > 0 else {return []}
1711

1812
// Step 1
1913
// Create an array to store the count of each element

0 commit comments

Comments
 (0)