We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fa2d4c3 commit 0e9a876Copy full SHA for 0e9a876
csharp/0205-isomorphic-strings.cs
@@ -0,0 +1,29 @@
1
+public class Solution {
2
+ public bool IsIsomorphic(string s, string t) {
3
+ Dictionary<string, string> mapST = new Dictionary<string, string>();
4
+ Dictionary<string, string> mapTS = new Dictionary<string, string>();
5
+
6
+ for (int i = 0; i < s.Length; i++) {
7
+ string sChar = s[i].ToString();
8
+ string tChar = t[i].ToString();
9
10
+ if (mapST.ContainsKey(sChar)) {
11
+ if (mapST[sChar] != tChar) {
12
+ return false;
13
+ }
14
+ } else {
15
+ mapST.Add(sChar, tChar);
16
17
18
+ if (mapTS.ContainsKey(tChar)) {
19
+ if (mapTS[tChar] != sChar) {
20
21
22
23
+ mapTS.Add(tChar, sChar);
24
25
26
27
+ return true;
28
29
+}
0 commit comments