import java.util.*; public class Same { public boolean checkSam(String str1, String str2) { // write code here if(str1.length() != str2.length()) return false; StringBuffer sb1 = new StringBuffer(str1); StringBuffer sb2 = new StringBuffer(str2); for(int i = 0; i < str1.length(); i++){ int tmp = sb2.indexOf(sb1.substring(i, i+1)); if(tmp == -1) return false; sb2.deleteCharAt(tmp); } if(sb2.length() == 0) return true; return false; } }
1.3---字符串重新排列后是否能够变成另一个字符串(CC150)
原文:http://www.cnblogs.com/yueyebigdata/p/5051795.html