Implement a function to check if two strings are isomorphic.
HardProblem Statement
Implement a function to check if two strings are isomorphic.
Sample Input
Two hardcoded strings, e.g., "egg" and "add".
Sample Output
The strings are isomorphic
Limits
Time: 2s · Memory: 256 MB
Code Editor
00:00
fun areIsomorphic(str1: String, str2: String): Boolean {
if (str1.length != str2.length) return false
val map1 = mutableMapOf<Char, Char>()
val map2 = mutableMapOf<Char, Char>()
for (i in str1.indices) {
val c1 = str1[i]
val c2 = str2[i]
if (map1[c1] != null && map1[c1] != c2
Input
Two hardcoded strings, e.g., "egg" and "add".
Expected Output
The strings are isomorphic