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; } }