205. Isomorphic Strings

Problem

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.

Note:
You may assume both s and t have the same length.

Example

Input: s = "egg", t = "add"
Output: true
Input: s = "foo", t = "bar"
Output: false
Input: s = "paper", t = "title"
Output: true

Code

static int var = [](){
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    return 0;
}();
class Solution {
public:
    bool isIsomorphic(string s, string t) {
        map dict;
        int exist[127] = {0};
        for(int i=0;i

Result

205. Isomorphic Strings_第1张图片
205. Isomorphic Strings.png

你可能感兴趣的:(205. Isomorphic Strings)