-
Notifications
You must be signed in to change notification settings - Fork 1
/
lintcode55.py
51 lines (48 loc) · 1.56 KB
/
lintcode55.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
'''
Compare two strings A and B, determine whether A contains all of the characters in B.
The characters in string A and B are all Upper Case letters.
Example:
For A = "ABCD", B = "ACD", return true.
For A = "ABCD", B = "AABC", return false.
'''
'''
class Solution:
"""
@param A : A string includes Upper Case letters
@param B : A string includes Upper Case letters
@return : if string A contains all of the characters in B return True else return False
"""
def compareStrings(self, A, B):
# write your code here
if B is None:
return True
else:
listA = A.split()
listB = B.split()
i = 0
while i < len(listB):
if listA[i] not in listA:
return False
break
else:
if listA.count(listB[i]) <= listB.count(listB[i]):
return False
break
else:
return True
continue
'''
class Solution:
"""
@param A : A string includes Upper Case letters
@param B : A string includes Upper Case letters
@return : if string A contains all of the characters in B return True else return False
"""
def compareStrings(self, A, B):
# write your code here
listA = sorted(A)
listB = sorted(B)
for b in listB:
if (b is not None) and ((b not in listA) or (listB.count(b) > listA.count(b))):
return False
return True