LeetCode 1002. Find Common Characters (查找常用字符)
题目标签:Array, Hash Table Java Solution: 完成日期:03/08/2019 关键点:对于每一个新的string,把common array 里面的次数进行更新,取最小的次数,排除不是 common 的 字符。 class Solution { public List<String> commonChars(String[] A) { List<String> result = new ArrayList<>(); int [] commonCharsCount = new int[26]; Arrays.fill(commonCharsCount, Integer.MAX_VALUE); // iterate each string in A for(String str : A) { int [] tempCharsCount = new int[26]; // count char for this string for(char c : str.toCharArray()) tempCharsCount[c - 'a']++; // update the commonCharsCount for(int i=0; i<commonCharsCount.length; i++) commonCharsCount[i] = Math.min