leetcode-205 Isomorphic Strings
来源:互联网 发布:macos日志式 Windows 编辑:程序博客网 时间:2024/04/29 21:12
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.
主要考察匹配映射。字符最多256个。
代码:
class Solution {public: bool isIsomorphic(string s, string t) { int m[256]={0}; int n[256]={0}; int l=s.size(); for(int i=0; i < l; i++) { if(m[s[i]] != n[t[i]]) return false; m[s[i]] = n[t[i]] = 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
- 机器学习中的数学-模型组合(Model Combining)之Boosting与Gradient Boosting
- Collected my Singapore passport at ICA
- Android中利用ViewHolder优化自定义Adapter的典型写法(讨论ViewHolder的修饰方式)
- 充实二叉树横向指针(算法)
- 优先队列
- leetcode-205 Isomorphic Strings
- 三马林达中文离线地图App上线
- hdu 1719 Friend 数学推导
- android入门学习-java简介
- afinal框架
- Face Alignment at 3000 FPS via Regressing Local Binary Features(CVPR2014)读后感(first pass)
- -2比2小吗? C++ 中 unsigned int 和 int的比较
- Objective-C(十四、NSDate类及日期格式化类NSDateFormatter)——iOS开发基础
- PDFLIB打印PDF,能输出中文英文