当前位置:网站首页>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;
}边栏推荐
- 1.5 what is an architect (serialization)
- About datasets
- JS for Fibonacci sequence
- Extracting strings with grep awk
- Nixos 22.05 installation process record
- A story on the cloud of the Centennial Olympic Games belonging to Alibaba cloud video cloud
- Random talk about redis source code 91
- Title 66: input 3 numbers a, B, C, and output them in order of size.
- Esp32-c3 esp-idf configuring smartconfig and SNTP to obtain network time
- js判断回文数
猜你喜欢

Virtual Lab Basic Experiment tutoriel - 4. Diffraction à fente unique

Overall flow chart of kernel interrupt

C language operation database (SQLite3) call interface function

USB to serial port - maximum peak serial port baud rate vs maximum continuous communication baud rate

Title 37: sorting 10 numbers

Typescript common types (I)

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

TypeScript常用类型(一)

Review of MySQL (I): go deep into MySQL

C#的变量
随机推荐
Introduction to service grid and istio - continued
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
torch. New usage of where (old but ignored usage)
迄今微软不同时期发布的SQL Server各版本之间的大致区别,供参考查阅
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
Vant3 +ts packaged simple step advancer component
Comparison of disk mapping tools for network disk and object cloud storage management
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
309. the best time to buy and sell stocks includes the freezing period
静态内存分配和动态内存分配小结
js判断回文数
Leetcode491 increasing subsequence
USB转串口那些事儿—最大峰值串口波特率VS连续通信最高波特率
Gd32f4xx controls dgus touch keys
Is it safe to open an account in flush
Write a select based concurrent server
leetcode 300. Longest increasing subsequence
机器学习系列(3):Logistic回归
Review of MySQL (3): query operation
Esp-idf adds its own components