Skip to content

Commit b4e555c

Browse files
author
Partho Biswas
committed
no message
1 parent 87cd500 commit b4e555c

File tree

1 file changed

+1
-16
lines changed

1 file changed

+1
-16
lines changed
Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1 @@
1-
class Solution {
2-
func groupStrings(_ strings: [String]) -> [[String]] {
3-
var groupMap = [String:[String]]()
4-
strings.forEach { string in
5-
let patttern = getPatternKey(string)
6-
groupMap[patttern, default: [String]()] += [string]
7-
}
8-
return Array(groupMap.values)
9-
}
10-
11-
func getPatternKey(_ string: String) -> String {
12-
let asciiValues = string.unicodeScalars.map({ Int($0.value) })
13-
let diffValue = asciiValues.map({ (26 + $0 - asciiValues[0]) % 26 })
14-
return diffValue.reduce("", { $0 + " \($1)" })
15-
}
16-
}
1+

0 commit comments

Comments
 (0)