文章作者:Tyan
博客:noahsnail.com | CSDN | 简书
1. Description
2. 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 resultdef match(self, query, pattern):i = 0j = 0while i < len(query) and j < len(pattern):if query[i] == pattern[j]:i += 1j += 1else:if query[i].isupper():return Falseelse:i += 1if j == len(pattern) and (i == len(query) or query[i:].islower()):return Truereturn False
Reference
- https://leetcode.com/problems/camelcase-matching/