当前位置:网站首页>2022.6.12-----leetcode. eight hundred and ninety
2022.6.12-----leetcode. eight hundred and ninety
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];// Storage pattern For each word Letters in
out:for(String word:words){
Arrays.fill(map,-1);
int mark=1<<26;// Mark the mapped word Letter
for(int j=0;j<pattern.length();j++){
//pattern Letters have no mapping
if(map[pattern.charAt(j)-'a']==-1){
if((mark&(1<<(word.charAt(j)-'a')))!=0)// Judge word Whether the letters have been mapped
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')// Judge pattern Whether to map the same letter
continue out;
}
}
ans.add(word);
}
return ans;
}边栏推荐
- ftrace
- Lenovo responded that there are too many and too messy notebooks: it is now the product adjustment period and will be divided into three series of digital /air/ pro in the future
- js求斐波那契数列
- VirtualLab basic experiment tutorial -4 Single slit diffraction
- js二分法
- USB转串口那些事儿—串口驱动类型
- Click the list page of vant3+ts+pinia tab to enter the details. The tab on the details page is highlighted in the original position, and the refresh highlight is in the first item by default
- 关于数据集
- 深圳3月14日起全市停工停业7天居家办公心得|社区征文
- VirtualLab基础实验教程-4.单缝衍射
猜你喜欢

Title 37: sorting 10 numbers

Pytest automated testing framework (II)

Analyzing mobx responsive refresh mechanism from source code

ES7 does not use parent-child and nested relationships to implement one to many functions

Basic SQL statement - select (single table query)

ESP-IDF 添加自己的组件

Remote gadget putty (Alibaba cloud mirror station address sharing)

企业架构的第一性原理

C language learning -- data storage in memory

从源码解析 MobX 响应式刷新机制
随机推荐
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
Pytest automated testing framework (II)
VirtualLab基础实验教程-4.单缝衍射
Comparison of disk mapping tools for network disk and object cloud storage management
【sql语句基础】——查(select)(单表查询)
leetcode 300. Longest increasing subsequence
leetcode 647. 回文子串
JS judge palindromes
js二分法
Machine learning series (3): logistic regression
Gospel of audio and video developers, rapid integration of AI dubbing capability
Topic 66: input array, exchange the largest element with the first element, exchange the smallest element with the last element, and output array.
C brief introduction
TypeScript类型声明文件(三)
Review of MySQL (4): sorting operation
HTTP cache < strong cache and negotiation cache >
Review of MySQL (I): go deep into MySQL
MYSQL:Expression #4 of SELECT list is not in GROUP BY clause and contains nonaggregated column
Summary of static memory allocation and dynamic memory allocation
Installation and configuration of window version pytorch entry depth learning environment