Leet_Code_567_字符串排列
public static boolean checkInclusion(String s1, String s2) { int[] charArray1 = new int[26]; int[] charArray2 = new int[26]; for (char c : s1.toCharArray()) { charArray1[c-'a'] ++; } int length = s1.length(); for (int i=0;i<s2.length();i++) { charArray2[s2.charAt(i) - 'a'] ++; if (i >= length) { int left = i-length; charArray2[s2.charAt(left)- 'a'] --; } if (Arrays.equals(charArray1, charArray2)) return true; } return false; }