Skip to content

Commit 62b3127

Browse files
committed
2019-08-19
1 parent 7afae5c commit 62b3127

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class Solution(object):
2+
def groupStrings(self, strings):
3+
"""
4+
:type strings: List[str]
5+
:rtype: List[List[str]]
6+
"""
7+
# O£¨N ^ 2£©
8+
record = collections.defaultdict(list)
9+
for i, word in enumerate(strings):
10+
tmp = tuple()
11+
for j in range(1, len(word)):
12+
num = ord(word[j]) - ord(word[j - 1])
13+
if num < 0:
14+
num += 26
15+
tmp += (j, num)
16+
record[tmp].append(word)
17+
18+
return record.values()

0 commit comments

Comments
 (0)