[LintCode] Compare Strings
public boolean compareStrings(String A, String B) { // write your code here int[] count_A = new int[26]; for(int i = 0; i < A.length(); i++) count_A[A.charAt(i)-'A']++; int[] count_B = new int[26]; for(int i = 0; i < B.length(); i++) count_B[B.charAt(i)-'A']++; for(int i = 0 ; i < 26; i++) { if(count_A[i]<count_B[i]) return false; } return true; }
Leave A Comment