-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path0249.py
More file actions
60 lines (40 loc) · 1.13 KB
/
0249.py
File metadata and controls
60 lines (40 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# 0249. Group Shifted Strings
# Given an array of strings (all lowercase), group them s.t. all strings in a group are shifted versions of each other.
# Two string S and T are called shifted (S[i] = T[i] + k for 1 <= i <= S.length
# ----------------------------------------------------------------------
# Clarifications:
#
# Inputs:
strings = {"acd", "dfg", "wyz", "yab", "mop", "bdfh", "a", "x", "moqs"};
# Output: a x
# acd dfg wyz yab mop
# bdfh moqs
# ----------------------------------------------------------------------
# Sol1: O() / O()
n = len(strings)
if n <= 1:
ans = []
ans = {}
for s in strings:
m = len(s)
if m not in ans:
ans{m} = s
string = "acd"
m = len(word)
for ch in string
for i in range(1,n):
diff = ord(word[i]) - ord(word[i-1])
diff = ord(ch) - ord(ch)
ord("a") - ord("b")
# ----------------------------------------------------------------------
# Submit: Sol1, O() / O()
class Solution:
def groupStrings(self, strings):
n = len(strings)
return n
# --------------
# Test:
sol = Solution()
print(sol.groupStrings(strings))
d = dict()
d{'1'} = 'a'