当前位置:网站首页>2022.6.12-----leetcode.890
2022.6.12-----leetcode.890
2022-06-12 18:23:00 【路Lu727】
public List<String> findAndReplacePattern(String[] words, String pattern) {
List<String> ans=new ArrayList<>();
int n=words.length;
int[] map=new int[26];//存儲pattern對應每個word中的字母
out:for(String word:words){
Arrays.fill(map,-1);
int mark=1<<26;//標記已經映射的word字母
for(int j=0;j<pattern.length();j++){
//pattern字母沒有映射
if(map[pattern.charAt(j)-'a']==-1){
if((mark&(1<<(word.charAt(j)-'a')))!=0)//判斷word字母是否已經映射
continue out;
map[pattern.charAt(j)-'a']=word.charAt(j)-'a';
mark|=1<<(word.charAt(j)-'a');
}else{
if(map[pattern.charAt(j)-'a']!=word.charAt(j)-'a')//判斷pattern是否映射同一字母
continue out;
}
}
ans.add(word);
}
return ans;
}边栏推荐
- AlibabaProtect. How to delete and uninstall exe
- leetcode 718 最长公共子串
- Can tonghuashun open an account? Can tonghuashun directly open the security of securities companies on the app
- This shift, I still have to go
- 有源差分晶振原理圖以及LV-PECL、LVDS、HCSL區別
- ftrace
- Title 66: input 3 numbers a, B, C, and output them in order of size.
- Regression analysis based on elasticnetcv
- leetcode 300. Longest increasing subsequence
- JS moves the 0 in the array to the end
猜你喜欢

Schematic diagram of active differential crystal oscillator and differences among lv-pecl, LVDS and HCSL

Mise en œuvre de l'ACL réflexe dans le simulateur Cisco Cisco Packet Tracer

C#简单介绍

有源差分晶振原理图以及LV-PECL、LVDS、HCSL区别

C语言练习(4)——大数乘除

Machine learning series (3): logistic regression

从源码解析 MobX 响应式刷新机制

Window版本pytorch入门深度学习环境安装与配置

Review of MySQL (V): Joint table query and sub query

HTTP缓存<强缓存与协商缓存>
随机推荐
Leetcode 718 longest common substring
在思科模擬器Cisco Packet Tracer實現自反ACL
Extracting strings with grep awk
This shift, I still have to go
es7不使用父子和嵌套关系来实现一对多功能
网盘和对象云存储管理之磁盘映射工具比较
Lambda - 1
面试题总结
Arrays in JS (including leetcode examples) < continuous update ~>
USB转串口那些事儿—串口驱动类型
Nixos 22.05 installation process record
机器学习系列(3):Logistic回归
从源码解析 MobX 响应式刷新机制
Review of MySQL (3): query operation
MySQL learning notes
关于数据集
Title 68: there are n integers, so that the previous numbers are moved backward m positions, and the last m numbers become the first m numbers
Gossip about the 88 of redis source code
企业架构的第一性原理
Review of MySQL (V): Joint table query and sub query