文章作者:Tyan
博客:noahsnail.com | CSDN | 简书
1. Description
Camelcase Matching2. Solution
- Version 1
class Solution:
def camelMatch(self, queries: List[str], pattern: str) -> List[bool]:
result = []
for i in range(len(queries)):
res = self.match(queries[i], pattern)
result.append(res)
return result
def match(self, query, pattern):
i = 0
j = 0
while i < len(query) and j < len(pattern):
if query[i] == pattern[j]:
i += 1
j += 1
else:
if query[i].isupper():
return False
else:
i += 1
if j == len(pattern) and (i == len(query) or query[i:].islower()):
return True
return False
网友评论