计算字符串中出现最多的字符和次数
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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