205. Isomorphic Strings
problem description
Given two strings s and t, determine if they are isomorphic.
Two strings 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 preserving the order of characters. No two characters may map to the same character but a character may map to itself.
Example 1:
Example 2:
Example 3:
algorithm thought
直接用map建立起两个字符串中每个字符之间的映射关系就很好解决
code
algorithm analysis
一次遍历,时间复杂度O(n),用了map和set保存映射关系,空间复杂度O(n)
Last updated