forked from illuz/leetcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAC_simulation_n.cpp
More file actions
43 lines (34 loc) · 849 Bytes
/
Copy pathAC_simulation_n.cpp
File metadata and controls
43 lines (34 loc) · 849 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
* Author: illuz <iilluzen[at]gmail.com>
* File: AC_simulation_n.cpp
* Create Date: 2015-05-01 10:04:38
* Descripton: Record and simulation
*/
#include <bits/stdc++.h>
using namespace std;
const int N = 0;
class Solution {
public:
bool isIsomorphic(string s, string t) {
if (s.length() != t.length())
return false;
vector<char> mp(300);
vector<bool> vis(300);
for (int i = 0; i < s.length(); ++i) {
if (mp[s[i]]) {
if (mp[s[i]] != t[i])
return false;
} else {
// char in t is visited
if (vis[t[i]])
return false;
mp[s[i]] = t[i];
vis[t[i]] = 1;
}
}
return true;
}
};
int main() {
return 0;
}