leetcode 205 Isomorphic Strings
来源:互联网 发布:常见面试算法题 编辑:程序博客网 时间:2024/06/08 05:32
Given two strings s and t, determine if they are isomorphic.
Two strings are isomorphic if the characters in s can be replaced to get t.
All occurrences of a character must be replaced with another character while preserving the order of characters. No two characters may map to the same character but a character may map to itself.
For example,
Given "egg"
, "add"
, return true.
Given "foo"
, "bar"
, return false.
Given "paper"
, "title"
, return true.
Note:
You may assume both s and t have the same length.
Subscribe to see which companies asked this question
class Solution {public:bool isIsomorphic(string s, string t) {vector<char> maps(255, 0);vector<int> visited(255, 0);for(int i = 0; i < s.length(); i++) {if(maps[s[i]]!=0) {if(maps[s[i]] != t[i]) return false;} else {if(visited[t[i]] == 1) return false;maps[s[i]]=t[i];visited[t[i]]=1;}}return true;}}
0 0
- LeetCode 205 - Isomorphic Strings
- [LeetCode 205]Isomorphic Strings
- LeetCode 205-Isomorphic Strings
- leetcode 205: Isomorphic Strings
- leetcode 205 Isomorphic Strings
- LeetCode 205:Isomorphic Strings
- leetcode-205 Isomorphic Strings
- Isomorphic Strings - LeetCode 205
- Isomorphic Strings leetcode 205
- leetcode 205:Isomorphic Strings
- leetcode-205 Isomorphic Strings
- Isomorphic Strings(leetcode 205)
- leetcode[205]:Isomorphic Strings
- leetcode-205-Isomorphic Strings
- leetcode 205: Isomorphic Strings
- leetcode: (205) Isomorphic Strings
- [LeetCode 205] Isomorphic Strings
- Leetcode----205Isomorphic Strings
- octave高画质图像处理字节数限制问
- 【Python学习日记】递归实现hanoi塔
- 2021发工资咯:)
- C语言基础 printf输出float与double型变量
- SDWebImage原理
- leetcode 205 Isomorphic Strings
- 有道词典python 代码(暂有缺憾)
- 学习心得体会
- 组件映射与继承映射
- 二分查找的算法思想和实现过程
- 详解Java集合框架的接口和类层次关系
- Android 实战美女拼图游戏 你能坚持到第几关
- 64位整型使用
- 将偶数的二进制反转