Five minutes. One pattern. Stay fluent.
Daily etudes
Ticket twins
Given two strings a and b of equal length, containing only lowercase Latin letters, determine whether they are isomorphic. Each letter in a must consistently correspond to one letter in b at the same positions, and different letters in a must correspond to different letters in b. Return a boolean. Two empty strings are isomorphic.
Example:
ticket_twins("aab", "xxy") → True
aab and xxy: two a’s map to two x’s, b maps to y.
ticket_twins("aba", "xyy") → False
aba and xyy fail because the first string’s first and last letters are the same, but x and y are not.
Pattern: hashmap - map each letter to its partner and check consistency both ways