class Solution {
public List<String> commonChars(String[] A) {
List<String> ans = new ArrayList<>();
if (A == null || A.length == 0)
return ans;
int[] hash = new int[26];
for (int i = 0; i < A[0].length(); i++) {
++hash[A[0].charAt(i) - 'a'];
}
int[] other = new int[26];
for (int i = 1; i < A.length; i++) {
Arrays.fill(other, 0);
for (int j = 0; j < A[i].length(); j++) {
++other[A[i].charAt(j) - 'a'];
};
for (int index = 0; index < 26; index++) {
hash[index] = Math.min(hash[index], other[index]);
}
}
for (int i = 0; i < 26; i++) {
while (hash[i] != 0) {
ans.add(new String("" + (char)('a' + i)));
--hash[i];
}
}
return ans;
}
}