是差点运气,可我一直在努力!
当前进程:
- 开始时间:2020.6.27
- 结束时间:undefined
GitHub仓库:https://github.com/Cundefined/JavaScript-or-TypeScript-for-LeetCode
1、题目要求
2、解题思路
1、统计第一个字符串的字符出现次数,之后用于更新为最小的出现次数
2、统计字符串数组中每个字符串的字符出现次数
2.1、遍历tempCount,把tempCount里统计的字频里的较小的值更新到minCount中
3、遍历minCount,统计结束后,把字频数组代表的字符转成字符,保存到结果数组
4、返回结果数组
2.1、JavaScript Solution
/**
* @param {string[]} A
* @return {string[]}
*/
var commonChars = function (A) {
const res = [];
if (A.length === 0) {
return res;
}
// 1、统计第一个字符串的字符出现次数,之后用于更新为最小的出现次数
const minCount = countChar(A[0]);
//2、统计字符串数组中每个字符串的字符出现次数
for (let i = 1; i < A.length; i++) {
let tempCount = countChar(A[i])