Isomorphic Strings
Hashing, Sorting, and Parsing DSA practice problem on Onlearn.
Difficulty: easy.
Topics: Isomorphic String Problem, Strings, Hash Tables, String Manipulation, Frequency Counting, string properties, hashing, mapping, string traversal, data structures, Isomorphic Strings, Character Mapping.
Given two strings s and t, determine if they are isomorphic. Two strings s and t are isomorphic if the characters in s can be replaced to get t. All occurrences of a character must be replaced with another character while maintaining the order of the characters. No two distinct characters may map to the same character, but a character may map to itself. Input The first line contains a string s. The second line contains a string t. Output Return true if s and t are isomorphic, false otherwise. Examples Example 1: Input: Output: Explanation: 'e' maps to 'a', 'g' maps to 'd'. Example 2: Input: Output: Explanation: 'o' maps to 'a' then 'r', which is inconsistent. Example 3: Input: Output: Explanation: 'p' maps to 't', 'a' maps to 'i', 'e' maps to 'l', 'r' maps to 'e'.