java 程序题 判断两个字符串是否是同构的(isIsomorphic)

import java.util.HashMap;
import java.util.Map;

public class IsomorphicStrings {
	public static void main(String[] args){
		System.out.println(isIsomorphic("egg", "add"));
		System.out.println(isIsomorphic("foo", "bar"));
		System.out.println(isIsomorphic("paper", "title"));
	}

	public static boolean isIsomorphic(String s, String t) {

		Map map_1 = new HashMap();
		Map map_2 = new HashMap();
		
		if(s.length() != t.length())
			return false;
		
		for(int i = 0;i
输出结果如下:
true
false
true
 
  

你可能感兴趣的:(java,程序题)