美文网首页Leetcode
Leetcode 1023. Camelcase Matchin

Leetcode 1023. Camelcase Matchin

作者: SnailTyan | 来源:发表于2021-05-07 15:20 被阅读0次

    文章作者:Tyan
    博客:noahsnail.com  |  CSDN  |  简书

    1. Description

    Camelcase Matching

    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 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
    

    Reference

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

    相关文章

      网友评论

        本文标题:Leetcode 1023. Camelcase Matchin

        本文链接:https://www.haomeiwen.com/subject/hyasdltx.html