【leetcode❤python】Ransom Note

时间:2024-01-03 18:26:20

#-*- 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')