C++ Version:
class Solution {
public:
/**
* @param A: A string includes Upper Case letters
* @param B: A string includes Upper Case letter
* @return: if string A contains all of the characters in B return true
* else return false
*/
bool compareStrings(string A, string B) {
// write your code here
int count[2][26] = {0};
for (int i = 0; i < A.length(); i++) {
count[0][A[i] - 'A']++;
}
for (int i = 0; i < B.length(); i++) {
count[1][B[i] - 'A']++;
}
for (int i = 0; i < 26; i++) {
if (count[0][i] < count[1][i]) {
return false;
}
}
return true;
}
};
Python Version:
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
a = list(A)
b = list(B)
for c in b:
if c not in a:
return False
a.remove(c)
return True