MCPcopy
hub / github.com/HuberTRoy/leetCode / wordPattern

Method wordPattern

String/WordPattern.py:36–47  ·  view source on GitHub ↗

:type pattern: str :type str: str :rtype: bool

(self, pattern, string)

Source from the content-addressed store, hash-verified

34"""
35class Solution(object):
36 def wordPattern(self, pattern, string):
37 """
38 :type pattern: str
39 :type str: str
40 :rtype: bool
41 """
42 pattern = list(pattern)
43 string = string.split(' ')
44 if len(pattern) != len(string):
45 return False
46 temp = len(set(zip(pattern, string)))
47 return temp == len(set(pattern)) and temp == len(set(string))

Callers

nothing calls this directly

Calls 1

splitMethod · 0.80

Tested by

no test coverage detected