@Test public void testIsPermutation() { assertTrue(isPermutation("abc", "cba")); assertTrue(isPermutation("aBc", "acB")); assertFalse(isPermutation("abc", "c")); assertFalse(isPermutation("abc", "def")); }
public static boolean isPermutation(String s1, String s2) { int len = s1.length(); if (s2.length() != len) { return false; } char[] charArr1 = s1.toCharArray(); char[] charArr2 = s2.toCharArray(); short sum1 = 0; short sum2 = 0; for (short i = 0; i < len; i++) { sum1 += ((short) charArr1[i]); sum2 += ((short) charArr2[i]); } return sum1 == sum2; }
PracticeQuestionsCh1 { public static boolean isPermutation(String s1, String s2) { int len = s1.length(); if (s2.length() != len) { return false; } char[] charArr1 = s1.toCharArray(); char[] charArr2 = s2.toCharArray(); short sum1 = 0; short sum2 = 0; for (short i = 0; i < len; i++) { sum1 += ((short) charArr1[i]); sum2 += ((short) charArr2[i]); } return sum1 == sum2; } }
PracticeQuestionsCh1 { public static boolean isPermutation(String s1, String s2) { int len = s1.length(); if (s2.length() != len) { return false; } char[] charArr1 = s1.toCharArray(); char[] charArr2 = s2.toCharArray(); short sum1 = 0; short sum2 = 0; for (short i = 0; i < len; i++) { sum1 += ((short) charArr1[i]); sum2 += ((short) charArr2[i]); } return sum1 == sum2; }  }
PracticeQuestionsCh1 { public static boolean isPermutation(String s1, String s2) { int len = s1.length(); if (s2.length() != len) { return false; } char[] charArr1 = s1.toCharArray(); char[] charArr2 = s2.toCharArray(); short sum1 = 0; short sum2 = 0; for (short i = 0; i < len; i++) { sum1 += ((short) charArr1[i]); sum2 += ((short) charArr2[i]); } return sum1 == sum2; }  static boolean isUnique(String s); static boolean isPermutation(String s1, String s2); static String encodeRepeatedChars(final String str); static void fillIfZero(int[][] matrix); static boolean isRotation(String s1, String s2); }
PracticeQuestionsCh1 { public static boolean isPermutation(String s1, String s2) { int len = s1.length(); if (s2.length() != len) { return false; } char[] charArr1 = s1.toCharArray(); char[] charArr2 = s2.toCharArray(); short sum1 = 0; short sum2 = 0; for (short i = 0; i < len; i++) { sum1 += ((short) charArr1[i]); sum2 += ((short) charArr2[i]); } return sum1 == sum2; }  static boolean isUnique(String s); static boolean isPermutation(String s1, String s2); static String encodeRepeatedChars(final String str); static void fillIfZero(int[][] matrix); static boolean isRotation(String s1, String s2); static final Logger LOGGER; }