class Solution(object):
def canConstruct(self, ransomNote, magazine):
"""
:type ransomNote: str
:type magazine: str
:rtype: bool
"""
for i in set(ransomNote):
if ransomNote.count(i) > magazine.count(i):
return False
return True
python,set(),count()

@CTD I have the intuition that all the methods of the original data structure(set,list,dictionary and string) are implemented by c, so we can't run the code faster using iteration or other codes that we write ourselves. For example,if we want to find a certain element in a list, using the index method is quicker than we write an iteration code ourselves. I think that is probably why python can be used in machine learning now, because lots of methods in the module numpy and scipy are implementd by c.

@CTD I think the complexity is O(n) because a dictionary is used as a data structure, like a string aaa, and the dictionary is like dict = {a:3} , so it takes O(1) to access the value . And the totally it is O(n)