Leetcode 1023. Camelcase Matching

暴力查找

class Solution:
def camelMatch(self, queries: List[str], pattern: str) -> List[bool]:
q_size=len(queries)
p_size=len(pattern)
ans=[True for i in range(q_size)]
for i,query in enumerate(queries):
idx=[query.find(pattern[0])]
if idx[-1]==-1:
ans[i]=False
continue
for p in pattern[1:]:
id = query[idx[-1]+1:].find(p)
if id==-1:
idx.append(-1)
break
else:
idx.append(idx[-1]+1+id)
if idx[-1]==-1:
ans[i]=False
continue
for j,v in enumerate(query):
if not (j in idx):
if not v.islower():
ans[i]=False
break
return ans
上一篇:C# System.Collections.SortedList


下一篇:SQL SERVER 2005快捷键+visual studio 2008 快捷键