File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed
Rabin-Karp/Rabin-Karp.playground Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ print("Hello, Swift 4!")
88import UIKit
99
1010struct Constants {
11- static let hashMultiplier = 69069
11+ static let hashMultiplier = 69061
1212}
1313
1414precedencegroup PowerPrecedence { higherThan : MultiplicationPrecedence }
@@ -30,8 +30,8 @@ extension Character {
3030// Find first position of pattern in the text using Rabin Karp algorithm
3131public func search( text: String , pattern: String ) -> Int {
3232 // convert to array of ints
33- let patternArray = pattern. flatMap { $0. asInt }
34- let textArray = text. flatMap { $0. asInt }
33+ let patternArray = pattern. compactMap { $0. asInt }
34+ let textArray = text. compactMap { $0. asInt }
3535
3636 if textArray. count < patternArray. count {
3737 return - 1
You can’t perform that action at this time.
0 commit comments