public boolean isScramble(String s1, String s2) {
		if (s1.length() != s2.length())
			return false;
		if (!hasSameChars(s1, s2))
			return false;
		if (s1.equals(s2))
			return true;
		for (int mid1 = 1; mid1 < s1.length(); mid1++) {
			int mid2 = s1.length() - mid1;
			String sub11 = s1.substring(0, mid1);
			String sub12 = s1.substring(mid1);
			// no swap
			String sub21 = s2.substring(0, mid1);
			String sub22 = s2.substring(mid1);
			if (isScramble(sub11, sub21) && isScramble(sub12, sub22))
				return true;
			// swap
			String bsub21 = s2.substring(0, mid2);
			String bsub22 = s2.substring(mid2);
			if (isScramble(sub11, bsub22) && isScramble(sub12, bsub21))
				return true;
		}
		return false;
	}