标签:
题目链接:https://leetcode.com/problems/isomorphic-strings/
题目:
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.
For example,
Given "egg"
, "add"
,
return true.
Given "foo"
, "bar"
,
return false.
Given "paper"
, "title"
,
return true.
Note:
You may assume both s and t have the same length.
思路:
用HashMap存储字符之间映射关系,要注意是双向映射即a映射到b,b也要映射到a,用hashmap要判断两次。
算法:
标签:
原文地址:http://blog.csdn.net/yeqiuzs/article/details/51622682