Match character patterns
Return whether two strings are isomorphic: each character maps to exactly one character in the other string in both directions. Lengths must match.
forward = {'a': 'x'}
reverse = {'x': 'a'}
print(reverse.get('x') == 'b') # collisionReason about the state
Maintain forward and reverse maps so two source characters cannot collide at one destination. Scan both strings together in linear time. Before writing code, identify what each variable means after one iteration. Walk through the example and explain why the next transition preserves that meaning. Then check the smallest permitted input and a case with repeated values. A correct answer follows the contract for every input, including the boundary cases in the checks. Keep any input mutation within the stated rules; return a fresh result when the task asks for one.
Your task
Return whether two strings are isomorphic: each character maps to exactly one character in the other string in both directions. Lengths must match.
The explanation opens here once every check passes.