205. Isomorphic Strings
来源:互联网 发布:有自己的域名凡科建站 编辑:程序博客网 时间:2024/05/14 14:00
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.
利用map 将两个数组映射成aabb这种格式,然后比较aabb是否等于aabb即可
class Solution {public: bool isIsomorphic(string s, string t) { map<char, char> m1;map<char, char> m2;int len = s.size();char x = 'a';char x2 = 'a';char table[128] = { 0 };for (int i = 0; i<s.length(); i++) {char c = s.at(i);char c2 = t.at(i);if (!m1[c]) {m1[c] = x++;}if (!m2[c2]){m2[c2] = x2++;}s[i] = m1[c];t[i] = m2[c2];} if(s==t) return true; else return false; }};
0 0
- 205. Isomorphic Strings
- 【LeetCode】205.Isomorphic Strings
- [leetcode] 205.Isomorphic Strings
- LeetCode 205. Isomorphic Strings
- 205. Isomorphic Strings
- 205. Isomorphic Strings LeetCode
- 205. Isomorphic Strings
- 205. Isomorphic Strings
- 205. Isomorphic Strings
- 205. Isomorphic Strings
- 205. Isomorphic Strings
- 205. Isomorphic Strings
- 205. Isomorphic Strings
- 【LeetCode】205. Isomorphic Strings
- LeetCode *** 205. Isomorphic Strings
- leetcode 205. Isomorphic Strings
- LeetCode 205. Isomorphic Strings
- 205. Isomorphic Strings
- Python基础-映射
- Java NIO系列教程(六) Selector
- ANDROID内存优化(大汇总——全)
- Spring3.0框架结构
- QT 二维码库
- 205. Isomorphic Strings
- 一位深度学习大神的博客网址
- 数字特征值
- 当cmd 不能正常使用时
- 进程 vs 线程 :一个进程可以包含多个线程
- spoj839 Optimal Marks (最小割经典模型 位拆分)
- js图片滚动
- #GWT#获取剪切板内容-getClipboardData
- iOS开发 地图:国内涉及到的地图坐标系的转换