Skip to content

Instantly share code, notes, and snippets.

@crimx
Created December 3, 2015 09:05
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save crimx/5ac48e7cfa81cd054015 to your computer and use it in GitHub Desktop.
计算字符串中出现最多的字符和次数
function count(s) {
var r = s.split('')
.sort()
.join('')
.match(/(\w)\1*/g)
.sort(function(a,b) {
return a.length < b.length
});
return {
letter: r[0],
count: r.length
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment