专栏首页SnailTyanLeetcode 1023. Camelcase Matching

Leetcode 1023. Camelcase Matching

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

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

我来说两句

0 条评论
登录 后参与评论

相关文章

  • Leetcode 【553、609、856、1003、1023】

    这道题是给一个数组,各个数字连除,通过加括号,使得除操作的结果最大。刚开始想着是遍历所有加括号的方式,然后求出最大结果。但是,发现加括号的规律很麻烦。

    echobingo
  • leetcode: 44. Wildcard Matching [✗]

    JNingWei
  • Leetcode Regular Expression Matching

    Given an input string (s) and a pattern (p), implement regular expression matchi...

  • leetcode Regular Expression Matching [rust]

    用户2436820
  • leetcode 10 Regular Expression Matching(简单正则表达式匹配)

    最近代码写的少了,而leetcode一直想做一个python,c/c++解题报告的专题,c/c++一直是我非常喜欢的,c语言编程练习的重要性体现在linux内核...

    流川疯
  • leetcode 10 Regular Expression Matching

    @坤的
  • Leetcode 10 Regular Expression Matching

    Implement regular expression matching with support for '.' and '*'. '.' Matches...

    triplebee
  • leetcode: 10. Regular Expression Matching [✗]

    JNingWei
  • 【LeetCode-010】Regular Expression Matching

    Given an input string (s) and a pattern (p), implement regular expression matchi...

    周三不加班

扫码关注云+社区

领取腾讯云代金券