We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7273dc7 commit b770513Copy full SHA for b770513
kotlin/0205-isomorphic-strings.kt
@@ -1,12 +1,16 @@
1
class Solution {
2
fun isIsomorphic(s: String, t: String): Boolean {
3
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
+
+ for (i in 0 until s.length) {
+ if (s[i] !in hm.keys) {
7
+ if (t[i] in hm.values) return false
8
hm.put(s[i], t[i])
- }else if (hm.get(s[i]) != t[i]) return false
9
+ } else if (hm.get(s[i]) != t[i]) {
10
+ return false
11
+ }
12
}
13
14
return true
15
16
0 commit comments