1. 程式人生 > >python leetcode 290. Word Pattern

python leetcode 290. Word Pattern

class Solution:
    def wordPattern(self, pattern, str):
        """
        :type pattern: str
        :type str: str
        :rtype: bool
        """ 
        list1=str.split(" ")
        if len(list1) != len(pattern):
            return False 
        return  len(set(pattern)) == len(set(list1)
) == len(set(zip(pattern, list1)))