当前位置:网站首页>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;
}
}
边栏推荐
- 智能面板WiFi聯動技術,ESP32無線芯片模組,物聯網WiFi通信應用
- C# TaskFactory. Startnew method
- Daily practice (28): balance binary tree
- leetcode797. All possible paths (medium)
- 命令执行漏洞详解
- Is there a row limit for a single MySQL table
- [SC] OpenService FAILED 5: Access is denied.
- Kill session? This cross domain authentication solution is really elegant!
- What does hard work mean to you?
- JSP实现银柜台业务绩效考核系统
猜你喜欢

Using datetime in MySQL

1. Mx6ull learning notes (II) - uboot migration

DS18B20数字温度计 (一) 电气特性, 供电和接线方式
![[official testerhome] MTSC 2021 Shanghai and Shenzhen PPT download addresses](/img/a0/d1170b20d01a7a586d8ff68279f1d4.jpg)
[official testerhome] MTSC 2021 Shanghai and Shenzhen PPT download addresses

Gavin teacher's perception of transformer live class - rasa dialogue robot project practice in the field of education agency mode and core component source code analysis under the microservice of educ
![[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

疫情数据分析平台工作报告【1】数据采集

Summary of sequential, modulelist, and moduledict usage in pytorch

MySQL master-slave construction and Django implementation of read-write separation

Introduction to distributed locks
随机推荐
What does kotlin collaboration scope and coroutinescope mainscope globalscope viewmodelscope lifecyclescope represent respectively
1. Mx6ull learning notes (II) - uboot migration
How to construct a search string?
R language plot visualization: plot visualization of basic 2D histogram, custom setting of color of 2D histogram, and histogram visualization of binary distribution (basic 2D histogram)
Recommended system cleaning tools, cocktail Download
Oracle:decode function
如何制作数据集并基于yolov5训练成模型并部署
Things to challenge
疫情数据分析平台工作报告【42】CodeNet
Ebpf series learning (4) learn about libbpf, co-re (compile once – run everywhere) | use go to develop ebpf programs (cloud native tool cilium ebpf)
[efficient] the most powerful development tool, ctool, is a compilation tool
千字巨著《编程后传》
Enterprise Architect v16
E-commerce middle office system architecture
Oracle's instr()
动规(14)-三角形最佳路径问题
Kotlin协程协程作用域,CoroutineScope MainScope GlobalScope viewModelScope lifecycleScope 分别代表什么
How do I extract files from the software?
AI and logistics Patent
windows如何安装多个版本mysql,如何同时启动