javascript实现

function getMaxCharNum(str) {
    var arr = str.split(''),hash = {},max = 0,maxItem;
    arr.forEach(function(item){
        if(hash[item]){
            hash[item]++;
        }
        else{
            hash[item]=1;
        }
        if(max < hash[item]){
            max = hash[item];
            maxItem = item;
        }
    });
    return {
        count:max,
        item:maxItem,
        hash:hash
    }
}

 

相关文章:

  • 2022-12-23
  • 2021-08-07
  • 2021-10-24
  • 2021-12-15
  • 2022-12-23
  • 2022-12-23
  • 2021-07-14
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-17
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案