leetcode刷题,总结,记录,备忘 205
来源:互联网 发布:不同域名对应同一个ip 编辑:程序博客网 时间:2024/05/29 04:34
leetcode205Isomorphic Strings
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.
一个字符串中的一个字母对应于另一个字符串中相同位置的字母,做两两映射,用2个127大小的数组来表达每个字符所对应的字符,全部初始化为0,在第一次映射的时候赋值,之后就可以做两两判断了。
class Solution {public: bool isIsomorphic(string s, string t) { vector<char> vs(127, 0); vector<char> vt(127, 0); for (int i = 0; i < s.size(); ++i) { if (vs[s[i]] == 0) { vs[s[i]] = t[i]; } if (vt[t[i]] == 0) { vt[t[i]] = s[i]; } if (vs[s[i]] != t[i] || vt[t[i]] != s[i]) { return false; } } return true; }};
0 0
- leetcode刷题,总结,记录,备忘 205
- leetcode刷题。总结,记录,备忘 104
- leetcode刷题。总结,记录,备忘 100
- leetcode刷题。总结,记录,备忘 191
- leetcode刷题。总结,记录,备忘。168
- leetcode刷题, 总结,记录,备忘 171
- leetcode刷题 ,总结,记录,备忘。144
- leetcode刷题,总结,记录, 备忘 141
- leetcode刷题,总结,记录,备忘。116
- leetcode刷题,总结,记录,备忘。96
- leetcode刷题。记录,总结,备忘。217
- leetcode 刷题, 总结,记录,备忘 35
- leetcode刷题,总结,记录,备忘 226
- leetcode刷题,总结,记录,备忘 169
- leetcode刷题,总结,记录,备忘137
- leetcode刷题,总结,记录,备忘83
- leetcode刷题,总结,记录,备忘70
- leetcode刷题,总结,记录,备忘 108
- servlet 实现验证码
- linux下libusb使用
- Apache Flink fault tolerance源码剖析(六)
- java的一些知识(八)
- CodeIgniter学习笔记 Item10--CI总结精华
- leetcode刷题,总结,记录,备忘 205
- 在嵌入式设备上运行高性能Java
- 局部变量加上static之后依然是局部变量
- 拥有 C/C++ 基础的学生,如何看懂1万行代码的项目
- Android源码浅析(三)——Android AOSP 5.1.1源码的同步sync和编译make,搭建Samba服务器进行更便捷的烧录刷机
- 两个对数组元素求和,求积的算法题
- 全球气象数据下载
- oracle中,被锁用户如何解锁
- 第3章 体会和表达感受