-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboj.cpp
77 lines (67 loc) · 1.6 KB
/
boj.cpp
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include<iostream>
#include<string>
#include<vector>
using namespace std;
class Solution {
public:
bool isIsomorphic(string s, string t) {
int len = s.length();
int num = 1;
vector<int> v, vv;
string str;
for (int i = 0; i < len; i++)
{
int idx = str.find(s[i]);
if (!idx)
{
//str.append(str(s[i]));
//string tmp(1, s[i]);
string tmp;
tmp.push_back(s[i]);
str.append(tmp);
v.push_back(num++);
}
else if(idx)
{
int j = s.find(s[i]);
v.push_back(j);
}
}
int numm = 1;
string strr;
for (int i = 0; i < len; i++)
{
int idx = str.find(t[i]);
if (!idx)
{
string tmp;
tmp.push_back(t[i]);
strr.append(tmp);
vv.push_back(numm++);
}
else if (idx)
{
int j = t.find(t[i]);
vv.push_back(j);
}
}
for (int i = 0; i < v.size(); i++)
cout << v[i] << " ";
cout << endl;
for (int i = 0; i < vv.size(); i++)
cout << vv[i] << " ";
cout << endl;
if (v == vv)
return true;
else
return false;
}
};
int main()
{
string s = "egg", t = "add";
cout << s.length() << "\n";
Solution sol = Solution();
sol.isIsomorphic(s, t);
return 0;
}