当前位置:网站首页>leetcode:6097. 替换字符后匹配【set记录 + 相同长度逐一查询】
leetcode:6097. 替换字符后匹配【set记录 + 相同长度逐一查询】
2022-06-12 18:36:00 【白速龙王的回眸】

分析
用set记录可替换的
然后就s找到长度和sub相同的
然后逐个看看如果不等的话能不能map过去
ac code
class Solution:
def matchReplacement(self, s: str, sub: str, mappings: List[List[str]]) -> bool:
n, m = len(s), len(sub)
mySet = set()
for x, y in mappings:
mySet.add((x, y))
#print(myDict)
for i in range(n - m + 1):
cankao = s[i: i + m]
#print(cankao)
flag = True
for j in range(m):
if sub[j] != cankao[j] and (sub[j], cankao[j]) not in mySet:
flag = False
break
if flag:
return True
return False
总结
简单set
边栏推荐
- Leetcode topic [string]-541- reverse string II
- Why my order by create_ Time ASC becomes order by ASC
- SCI Writing - Results
- 基于Halcon的矩形卡片【手动绘制ROI】的自由测量
- 01 complexity
- General differences between SQL server versions released by Microsoft in different periods so far, for reference
- The difference between user status and system status in CRM
- 收获满满的下午
- A story on the cloud of the Centennial Olympic Games belonging to Alibaba cloud video cloud
- Quickly copy the request in browser F12 to postman/ or generate the corresponding code of the relevant language
猜你喜欢

在思科模拟器Cisco Packet Tracer实现自反ACL

Title 37: sorting 10 numbers

Research Report on the overall scale, major manufacturers, major regions, products and applications of Electric Screwdrivers in the global market in 2022

Remote gadget putty (Alibaba cloud mirror station address sharing)

干货 | 一文搞定 pytest 自动化测试框架(二)
![[blockbuster release] ant dynamic card, enabling the app home page to realize agile update](/img/65/5ed80090f4d0ee92b01888eb496528.jpg)
[blockbuster release] ant dynamic card, enabling the app home page to realize agile update

PHP:Fatal error: Allowed memory size of 262144 bytes exhausted (tried to allocat

GD32F4xx控制DGUS触控按键

To understand Devops, you must read these ten books!

在思科模擬器Cisco Packet Tracer實現自反ACL
随机推荐
静态内存分配和动态内存分配小结
Pytest automated testing framework (II)
OpenGL shadow implementation (hard shadow)
快速复制浏览器F12中的请求到Postman/或者生成相关语言的对应代码
Self made calculator (1 realized by Boolean logic operation unit and control unit programming)
wireshark基本使用命令
Partial scratch and corrosion detection of bolts and screws based on Halcon
01 complexity
Review of MySQL (V): Joint table query and sub query
Gd32f4xx controls dgus touch keys
torch.where的新用法(很老但是大家忽略的用法)
Solution to the problem that the anaconda navigator card logo cannot be opened and the card will flash back - replace the alicloud image source
MySQL数据库(28):变量 variables
Quickly copy the request in browser F12 to postman/ or generate the corresponding code of the relevant language
Comparison of disk mapping tools for network disk and object cloud storage management
看不懂Kotlin源码?从Contracts 函数说起~
在思科模擬器Cisco Packet Tracer實現自反ACL
Research Report on the overall scale, major manufacturers, major regions, products and applications of Electric Screwdrivers in the global market in 2022
MYSQL:Expression #4 of SELECT list is not in GROUP BY clause and contains nonaggregated column
从源码解析 MobX 响应式刷新机制