当前位置: 代码迷 >> 综合 >> Leetcode 1023. Camelcase Matching
  详细解决方案

Leetcode 1023. Camelcase Matching

热度:76   发布时间:2023-12-12 21:09:33.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 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

  1. https://leetcode.com/problems/camelcase-matching/
  相关解决方案