Skip to content

Commit 79348b2

Browse files
authored
Merge pull request #33 from Fundebug/master
Code bug fix: 2.3 Check if a given string is a isomorphic
2 parents b4dee8f + 92435ea commit 79348b2

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

README.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,12 @@
307307
// If the letter does not exist, create a map and map it to the value
308308
// of the second letter
309309
if (letterMap[letterA] === undefined) {
310-
letterMap[letterA] = letterB;
310+
// If letterB has already been added to letterMap, then we can say: they are not isomorphic.
311+
if(secondString.indexOf(letterB) < i){
312+
return false;
313+
} else {
314+
letterMap[letterA] = letterB;
315+
}
311316
} else if (letterMap[letterA] !== letterB) {
312317
// Eles if letterA already exists in the map, but it does not map to
313318
// letterB, that means that A is mapping to more than one letter.

0 commit comments

Comments
 (0)