Skip to content

Commit ee9652a

Browse files
author
lightmen
committed
add word-pattern[1].py
1 parent f15f93e commit ee9652a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class Solution(object):
2+
def wordPattern(self, pattern, str):
3+
"""
4+
:type pattern: str
5+
:type str: str
6+
:rtype: bool
7+
"""
8+
words = str.split()
9+
return map(pattern.find, pattern) == map(words.index, words)

0 commit comments

Comments
 (0)