ScrambleString { public boolean isScramble(String s1, String s2) { if (s1.length() != s2.length()) { return false; } if (s1.equals(s2)) { return true; } HashMap<Character, Integer> hm1 = new HashMap<>(), hm2 = new HashMap<>(); for (char c: s1.toCharArray()) { hm1.put(c, hm1.getOrDefault(c, 0) + 1); } for (char c: s2.toCharArray()) { hm2.put(c, hm2.getOrDefault(c, 0) + 1); } return hm1.equals(hm2); }  boolean isScramble(String s1, String s2);  }
@Test(dataProvider = "testStrings") public void test(String str1, String str2, boolean isScarmbled) { assertEquals(new ScrambleString().isScramble(str1, str2), isScarmbled, String.format("str1 = %s, str2 = %s", str1, str2)); }