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)))
python leetcode 290. Word Pattern
猜你喜欢
转载自blog.csdn.net/Neekity/article/details/85135934
今日推荐
周排行