205. Isomorphic Strings 發表於 2023-02-13 | 分類於 leetcode problemsolution123456789101112131415class Solution {public: bool isIsomorphic(string s, string t) { unordered_map<char, int> mpa, mpb; int n = s.size(), m=t.size(); if(m!=n) return false; for(int i=0;i<n;++i){ if(mpa[s[i]]!=mpb[t[i]]) return false; mpa[s[i]] = i+1; mpb[t[i]] = i+1; } return true; }}; analysis time complexity O(nlogn) space complexity O(n)