Skip to content

Commit

Permalink
Create 0205-isomorphic-strings.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
a93a committed Jan 25, 2023
1 parent 766ba49 commit aab99f6
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions kotlin/0205-isomorphic-strings.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class Solution {
fun isIsomorphic(s: String, t: String): Boolean {
val hm = HashMap<Char, Char>()
for(i in 0 until s.length){
if(s[i] !in hm.keys){
if(t[i] in hm.values) return false
hm.put(s[i], t[i])
}else if (hm.get(s[i]) != t[i]) return false
}
return true
}
}

0 comments on commit aab99f6

Please sign in to comment.