File tree 2 files changed +28
-0
lines changed
2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change 133
133
202|[ Happy Number] ( ./0202-happy-number.js ) |Easy|
134
134
203|[ Remove Linked List Elements] ( ./0203-remove-linked-list-elements.js ) |Easy|
135
135
204|[ Count Primes] ( ./0204-count-primes.js ) |Medium|
136
+ 205|[ Isomorphic Strings] ( ./0205-isomorphic-strings.js ) |Easy|
136
137
206|[ Reverse Linked List] ( ./0206-reverse-linked-list.js ) |Easy|
137
138
207|[ Course Schedule] ( ./0207-course-schedule.js ) |Medium|
138
139
213|[ House Robber II] ( ./0213-house-robber-ii.js ) |Medium|
Original file line number Diff line number Diff line change
1
+ /**
2
+ * 205. Isomorphic Strings
3
+ * https://leetcode.com/problems/isomorphic-strings/
4
+ * Difficulty: Easy
5
+ *
6
+ * Given two strings s and t, determine if they are isomorphic.
7
+ *
8
+ * Two strings s and t are isomorphic if the characters in s can be replaced to get t.
9
+ *
10
+ * All occurrences of a character must be replaced with another character while preserving
11
+ * the order of characters. No two characters may map to the same character, but a character
12
+ * may map to itself.
13
+ */
14
+
15
+ /**
16
+ * @param {string } s
17
+ * @param {string } t
18
+ * @return {boolean }
19
+ */
20
+ var isIsomorphic = function ( s , t ) {
21
+ for ( let i = 0 ; i < s . length ; i ++ ) {
22
+ if ( s . indexOf ( s [ i ] , i + 1 ) !== t . indexOf ( t [ i ] , i + 1 ) ) {
23
+ return false ;
24
+ }
25
+ }
26
+ return true ;
27
+ } ;
You can’t perform that action at this time.
0 commit comments