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 } }