📅  最后修改于: 2022-03-11 15:04:15.283000             🧑  作者: Mango
const getRepeatedChars = (str) => {
let result = [];
str.map(each => {
let repeatedChars = 0;
for (let i = 0; i < each.length - 1; i++) {
if (each[i] === each[i + 1] && each[i] !== each[i - 1]) {
repeatedChars += 1;
}
}
result.push(repeatedChars);
});
return result;
};
getRepeatedChars(["aaabbbkdnndicccoekdczufnrz", "awsfgds"]); // [4, 0]