-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path211.py
37 lines (33 loc) · 856 Bytes
/
211.py
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
class Solution:
"""
@param A: a string
@param B: a string
@return: a boolean
"""
def Permutation(self, A, B):
# write your code here
if not A and not B:
return True
if not A or not B:
return False
if len(A) != len(B):
return False
dicA = {}
for a in A:
if not a in dicA:
dicA[a] = 0
else:
dicA[a] += 1
dicB = {}
for b in B:
if not b in dicB:
dicB[b] = 0
else:
dicB[b] += 1
for key, val in dicA.items():
if key in dicB:
if dicB[key] != val:
return False
else:
return False
return True