当前位置:网站首页>2022.6.12 - leetcode. 89.
2022.6.12 - leetcode. 89.
2022-06-12 18:23:00 【Lu 727】
public List<String> findAndReplacePattern(String[] words, String pattern) {
List<String> ans=new ArrayList<>();
int n=words.length;
int[] map=new int[26];//StockagepatternCorrespond à chaquewordLes lettres de
out:for(String word:words){
Arrays.fill(map,-1);
int mark=1<<26;//Étiquette déjà cartographiéewordLettres
for(int j=0;j<pattern.length();j++){
//patternLes lettres ne sont pas cartographiées
if(map[pattern.charAt(j)-'a']==-1){
if((mark&(1<<(word.charAt(j)-'a')))!=0)//JugementwordSi les lettres ont été cartographiées
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')//Jugementpattern Si la même lettre est cartographiée
continue out;
}
}
ans.add(word);
}
return ans;
}边栏推荐
- Gossip about the 88 of redis source code
- Installation and configuration of window version pytorch entry depth learning environment
- torch.where的新用法(很老但是大家忽略的用法)
- leetcode 647. Palindrome substring
- js求斐波那契数列
- Strings in JS (including leetcode examples) < continuous update ~>
- JS quick sort
- GD32F4xx 与符合DLT645的电能表通信_2
- 在同花顺开户证券安全吗
- leetcode151 翻转字符串里的单词
猜你喜欢

PHP implementation of infinite classification tree (recursion and Optimization)

C language operation database (SQLite3) call interface function

js求斐波那契数列

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

GD32F4xx控制DGUS 变量显示

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

JS sum of two numbers

LCD parameter interpretation and calculation

Review of MySQL (4): sorting operation

Machine learning series (3): logistic regression
随机推荐
GD32F4xx 与符合DLT645的电能表通信_2
Section qemu+gdb
企业架构的第一性原理
低代码平台调研结果
深圳3月14日起全市停工停业7天居家办公心得|社区征文
Solution to the problem that the anaconda navigator card logo cannot be opened and the card will flash back - replace the alicloud image source
Pytest automated testing framework (II)
Random talk about redis source code 90
C brief introduction
Changes in the third generation dri
Leetcode151 flipping words in strings
C business serial number rule generation component
Summary of interview questions
有源差分晶振原理图以及LV-PECL、LVDS、HCSL区别
leetcode 647. 回文子串
When openharmony meets openeuler
C语言练习(4)——大数乘除
Title 37: sorting 10 numbers
Global lock, table lock, row lock
DRM driven MMAP detailed explanation: (I) preliminary knowledge