File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -156,6 +156,28 @@ var isIsomorphic = function(s, t) {
156
156
};
157
157
```
158
158
159
+ ## TypeScript
160
+
161
+ ``` typescript
162
+ function isIsomorphic(s : string , t : string ): boolean {
163
+ const helperMap1: Map <string , string > = new Map ();
164
+ const helperMap2: Map <string , string > = new Map ();
165
+ for (let i = 0 , length = s .length ; i < length ; i ++ ) {
166
+ let temp1: string | undefined = helperMap1 .get (s [i ]);
167
+ let temp2: string | undefined = helperMap2 .get (t [i ]);
168
+ if (temp1 === undefined && temp2 === undefined ) {
169
+ helperMap1 .set (s [i ], t [i ]);
170
+ helperMap2 .set (t [i ], s [i ]);
171
+ } else if (temp1 !== t [i ] || temp2 !== s [i ]) {
172
+ return false ;
173
+ }
174
+ }
175
+ return true ;
176
+ };
177
+ ```
178
+
179
+
180
+
159
181
160
182
-----------------------
161
183
<div align="center"><img src=https://code-thinking.cdn.bcebos.com/pics/01二维码一.jpg width=500> </img ></div >
You can’t perform that action at this time.
0 commit comments