-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path567.py
More file actions
66 lines (54 loc) · 1.4 KB
/
567.py
File metadata and controls
66 lines (54 loc) · 1.4 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
61
62
##
s1 = "a"
s2 = "ab"
from collections import Counter
class Solution:
def checkInclusion(self, s1, s2):
C = Counter(s1)
window = None
k=len(s1)
i=0
while i<len(s2)-k+1:
if i == 0:
window = Counter(s2[:len(s1)])
if C==window:
return True
print(window)
i+=1
else:
minus = {s2[i-1]:1}
plus = {s2[i+k-1]:1}
window -= minus
window += plus
print(window)
if C==window:
return True
i+=1
return False
Solution().checkInclusion(s1,s2)
##
Input="ABC"
from itertools import permutations
class Solution:
def numTilePossibilities(self, tiles):
res = []
for i in range(1, len(tiles)+1):
res += list(permutations(tiles,i))
return len(set(res))
Solution().numTilePossibilities(Input)
##
class Solution:
def generate(self, numRows):
n = 0
b = [1]
res = []
while n<numRows:
res.append(b)
b = [1] + [b[i]+b[i+1] for i in range(len(b)-1)] + [1]
n+=1
return res
Solution().generate(5)
##
S = "abbaca"
print(S)
##