Leetcode 1080 Solution

This article provides solution to leetcode question 1080 (camelcase-matching)

https://leetcode.com/problems/camelcase-matching

Solution

class Solution:
    def camelMatch(self, queries: List[str], pattern: str) -> List[bool]:
        ans = []
        for query in queries:
            i, j = 0, 0
            while i < len(query):
                if j < len(pattern) and query[i] == pattern[j]:
                    j += 1
                elif 'A' <= query[i] <= 'Z':
                    break
                i += 1
            ans.append(i == len(query) and j == len(pattern))

        return ans