当前位置:网站首页>leetcode 205. Isomorphic Strings
leetcode 205. Isomorphic Strings
2022-06-12 04:29:00 【kt1776133839】
Title Description :
Given two strings s and t , Judge whether they are isomorphic .
If s The characters in can be replaced according to some mapping relationship t , So these two strings are isomorphic .
Every character that appears should be mapped to another character , Without changing the order of characters . Different characters cannot be mapped to the same character , The same character can only be mapped to the same character , Characters can be mapped to themselves .
Examples :
Example 1:
Input :s = "egg", t = "add"
Output :true
Example 2:
Input :s = "foo", t = "bar"
Output :false
Example 3:
Input :s = "paper", t = "title"
Output :true
Tips :
1 <= s.length <= 5 * 104
t.length == s.length
s and t By any valid ASCII Character composition
Java Program :
class Solution {
public boolean isIsomorphic(String s, String t) {
Map<Character, Character> s2t = new HashMap<Character, Character>();
Map<Character, Character> t2s = new HashMap<Character, Character>();
int len = s.length();
for (int i = 0; i < len; ++i) {
char x = s.charAt(i), y = t.charAt(i);
if ((s2t.containsKey(x) && s2t.get(x) != y) || (t2s.containsKey(y) && t2s.get(y) != x)) {
return false;
}
s2t.put(x, y);
t2s.put(y, x);
}
return true;
}
}
边栏推荐
- What is the difference between FOB, CIF and CFR?
- [automation] generate xlsx report based on openstack automated patrol deployed by kolla
- Notes on relevant knowledge points such as original code / inverse code / complement code, size end, etc
- Recommended system cleaning tools, cocktail Download
- Emperor Wu of Wei knew that he could not correct it, so he stopped offering his words
- 数据库新建表,以前没问题的,今天
- Install/Remove of the Service Denied!
- Bearpi IOT lighting LED
- Labor
- Let me tell you the benefits of code refactoring
猜你喜欢
![[wechat applet] the mobile terminal selects and publishes pictures](/img/9a/46bc4a7bf9b70d26b0e24fe02f747d.jpg)
[wechat applet] the mobile terminal selects and publishes pictures

Bearpi IOT lighting LED
![[FPGA chaos] implementation of FPGA based chaotic system Verilog](/img/c0/cda4644168264b7531b67ef16e801a.png)
[FPGA chaos] implementation of FPGA based chaotic system Verilog
![[efficient] the most powerful development tool, ctool, is a compilation tool](/img/23/a5eb401affd64119590db273d60c23.png)
[efficient] the most powerful development tool, ctool, is a compilation tool
![[软件工具][原创]voc数据集类别名批量修改工具使用教程](/img/25/31d771c9770bb7f455f35e38672170.png)
[软件工具][原创]voc数据集类别名批量修改工具使用教程

怎样拥有心灵的平和?获得一颗全新的心灵

leetcode797. All possible paths (medium)

DS18B20 digital thermometer (I) electrical characteristics, power supply and wiring mode

Esp32c3 remote serial port

Brief introduction to 44 official cases of vrtk3.3 (combined with steamvr)
随机推荐
疫情数据分析平台工作报告【1】数据采集
[C language] analysis of variable essence
Work report of epidemic data analysis platform [1] data collection
1. Mx6ull learning notes (II) - uboot migration
These programming languages are worth learning
windows如何安装多个版本mysql,如何同时启动
[official testerhome] MTSC 2021 Shanghai and Shenzhen PPT download addresses
C# Task. Waitall method
Work report of epidemic data analysis platform [6] visual drawing
Plot visualization in R language: visualize the scatter diagram of the actual value and the predicted value of the regression model, analyze the prediction efficiency of the regression model, distingu
调用提醒事项
Oracle's instr()
Legendary biological car-t has been approved by FDA, becoming the first domestic cell therapy product to successfully go to sea
eBPF系列学习(4)了解libbpf、CO-RE (Compile Once – Run Everywhe) | 使用go开发ebpf程序(云原生利器cilium ebpf )
Is it safe for Guojin Securities Commission Jinbao to open an account? How should we choose securities companies?
JS function and variable have the same name (function and variable parsing rules)
树莓派4B使用Intel Movidius NCS 2来进行推断加速
SqEL简单上手
R language uses the coxph function of survival package to build Cox regression model, uses the ggrisk function of ggrisk package to visualize the risk score map (risk score map) of Cox regression, and
请用递归的方法计算下列函数的值:px(x,n)=x-x^2 +x^3- x^4+… ((-1)n-1)(xn) n>0 **输入格式要求:“%lf%d“ 提示信息:“Enter X and N:”