From 62b31278d594354c1c766ae221cb2361d6f8f4bf Mon Sep 17 00:00:00 2001 From: Celia_Wu <530081999@qq.com> Date: Mon, 19 Aug 2019 23:57:51 -0400 Subject: [PATCH] 2019-08-19 --- ...246\344\270\262\345\210\206\347\273\204.py" | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 "0249.\347\247\273\344\275\215\345\255\227\347\254\246\344\270\262\345\210\206\347\273\204/0249-\347\247\273\344\275\215\345\255\227\347\254\246\344\270\262\345\210\206\347\273\204.py" diff --git "a/0249.\347\247\273\344\275\215\345\255\227\347\254\246\344\270\262\345\210\206\347\273\204/0249-\347\247\273\344\275\215\345\255\227\347\254\246\344\270\262\345\210\206\347\273\204.py" "b/0249.\347\247\273\344\275\215\345\255\227\347\254\246\344\270\262\345\210\206\347\273\204/0249-\347\247\273\344\275\215\345\255\227\347\254\246\344\270\262\345\210\206\347\273\204.py" new file mode 100644 index 0000000..e258b15 --- /dev/null +++ "b/0249.\347\247\273\344\275\215\345\255\227\347\254\246\344\270\262\345\210\206\347\273\204/0249-\347\247\273\344\275\215\345\255\227\347\254\246\344\270\262\345\210\206\347\273\204.py" @@ -0,0 +1,18 @@ +class Solution(object): + def groupStrings(self, strings): + """ + :type strings: List[str] + :rtype: List[List[str]] + """ + # O£¨N ^ 2£© + record = collections.defaultdict(list) + for i, word in enumerate(strings): + tmp = tuple() + for j in range(1, len(word)): + num = ord(word[j]) - ord(word[j - 1]) + if num < 0: + num += 26 + tmp += (j, num) + record[tmp].append(word) + + return record.values() \ No newline at end of file