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
Leetcode 1023. Camelcase Matching的更多相关文章
- 【LEETCODE】70、字符匹配1023 Camelcase Matching
最近做leetcode总感觉自己是个智障,基本很少有题能自己独立做出来,都是百度... 不过终于还是做出了一题...而且速度效率还可以 哎,加油吧,尽量锤炼自己 package y2019.Algor ...
- 【LeetCode】1023. Camelcase Matching 解题报告(Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 正则+字典 日期 题目地址:https://leet ...
- 【leetcode】1023. Camelcase Matching
题目如下: A query word matches a given pattern if we can insert lowercaseletters to the pattern word so ...
- 1023. Camelcase Matching驼峰式匹配
网址:https://leetcode.com/problems/camelcase-matching/ 依题意可得逻辑 class Solution { public: vector<bool ...
- [LeetCode] Regular Expression Matching 正则表达式匹配
Implement regular expression matching with support for '.' and '*'. '.' Matches any single character ...
- Java for LeetCode 044 Wildcard Matching
Implement wildcard pattern matching with support for '?' and '*'. '?' Matches any single character. ...
- LeetCode | Regular Expression Matching
Regular Expression Matching Implement regular expression matching with support for '.' and '*'. '.' ...
- [leetcode]Regular Expression Matching @ Python
原题地址:https://oj.leetcode.com/problems/regular-expression-matching/ 题意: Implement regular expression ...
- [LeetCode] 44. Wildcard Matching 外卡匹配
Given an input string (s) and a pattern (p), implement wildcard pattern matching with support for '? ...
随机推荐
- django基础之Ajax、分页、cookie与session
目录: Ajax之json Ajax简介 jquery实现的ajax js实现的ajax django分页器 COOKIE与SESSION 一.Ajax之json 1.什么是json? 定义: JSO ...
- Spark Core (一) 什么是RDD的Transformation和Action以及Dependency(转载)
1. Spark的RDD RDD(Resilient Distributed Datasets),弹性分布式数据集,是对分布式数据集的一种抽象. RDD所具备5个主要特性: 一组分区列表 计算每一个数 ...
- python16_day40【数据结构】
一.链表 #!/usr/bin/env python # -*-coding:utf8-*- __author__ = "willian" # 一.简单链表 class Node( ...
- 田忌赛马Java解答
你一定听过田忌赛马的故事吧? 如果3匹马变成1000匹,齐王仍然让他的马按从优到劣的顺序出赛,田忌可以按任意顺序选择他的赛马出赛.赢一局,田忌可以得到200两银子,输一局,田忌就要输掉200两 ...
- 11月26号host
127.0.0.1 localhost255.255.255.255 broadcasthost::1 localhostfe80::1%lo0 localhost # Google start216 ...
- docker 容器目录挂载 | 进出容器
docker run --name wnginx -d -p 9001:80 -v /home/www:/usr/share/nginx/html nginx --name 别名 -d ...
- HTTP从入门到入土(2)——HTTP协议发展历史
HTTP协议的发展历史 HTTP/0.9 0.9版本是第一个定稿的HTTP版本,相对较为简陋.它有以下特点: 只有一个命令GET 没有header等描述数据的信息 服务器发送完毕,就关闭TCP连接 注 ...
- 【运维技术】CentOS7上从零开始安装LAMP安装织梦DedeCMS教程
前期准备数据 centos7 系统 安装 appache httpd # 更新httpd yum update httpd # 安装httpd yum install -y httpd # 启动服务 ...
- Redis设置Auth认证保护
redis有一个认证方式来保护数据的安全.设置此认证有两种方式,一种是通过配置文件,一个是在redis客户端命令直接设定 一.配置文件(需要重启redis生效) 找到参数 requirepass, 这 ...
- Stitching模块中focalsFromHomography初步研究
在Stitching模块中,通过“光束法平差”的时候,有一个步骤为“通过单应矩阵估算摄像头焦距”,调用的地方为: , )); ] ]; d2 ] ]) ] ]); v1 ] ] ...