Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Implement a function to check if two strings are isomorphic.

Hard

Problem 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
Log in or sign up to run or submit your code.Log inSign up
Input
Two hardcoded strings, e.g., "egg" and "add".
Expected Output
The strings are isomorphic