Skip to content

Commit b770513

Browse files
authored
Update 0205-isomorphic-strings.kt
1 parent 7273dc7 commit b770513

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

kotlin/0205-isomorphic-strings.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
class Solution {
22
fun isIsomorphic(s: String, t: String): Boolean {
33
val hm = HashMap<Char, Char>()
4-
for(i in 0 until s.length){
5-
if(s[i] !in hm.keys){
6-
if(t[i] in hm.values) return false
4+
5+
for (i in 0 until s.length) {
6+
if (s[i] !in hm.keys) {
7+
if (t[i] in hm.values) return false
78
hm.put(s[i], t[i])
8-
}else if (hm.get(s[i]) != t[i]) return false
9+
} else if (hm.get(s[i]) != t[i]) {
10+
return false
11+
}
912
}
13+
1014
return true
1115
}
1216
}

0 commit comments

Comments
 (0)