首页 > 代码库 > 【leetcode?python】Ransom Note

【leetcode?python】Ransom Note

#-*- coding: UTF-8 -*-
class Solution(object):   
    def canConstruct(self, ransomNote, magazine):
        ransomNote=list(ransomNote)
        magezine=list(magazine)
        
        for ransom in ransomNote:
            if(magezine.__contains__(ransom)):
                point=magezine.index(ransom)
                del magezine[point]
            else:
                return False
        
        return True
    
sol=Solution()
print sol.canConstruct(‘aa‘, ‘aab‘)

【leetcode?python】Ransom Note