Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

查找字符串中出现最多的字符和个数:Ruby #2

Open
ben7th opened this issue May 28, 2014 · 1 comment
Open

查找字符串中出现最多的字符和个数:Ruby #2

ben7th opened this issue May 28, 2014 · 1 comment

Comments

@ben7th
Copy link
Contributor

ben7th commented May 28, 2014

str.split('').uniq.map {|x| [x, str.count(x)]}.sort{|a,b| b[1]<=>a[1]}[0]
str = "sdsdsddssssssdd"
str.split('').uniq.map {|x| [x, str.count(x)]}.sort{|a,b| b[1]<=>a[1]}[0]
# => ["s", 9]
@qiwsir
Copy link
Owner

qiwsir commented May 28, 2014

can you git push these codes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants