-
Notifications
You must be signed in to change notification settings - Fork 0
205_IsomorphicStrings
a920604a edited this page Apr 14, 2023
·
1 revision
class 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;
}
};
- time complexity
O(nlogn)
- space complexity
O(n)
footer