Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def solve s, k
- h = Hash.new(0)
- s.chars.sort[0...k].each { |e| h[e.to_sym] += 1 }
- s.chars.each.inject('') { |m, v| h[v.to_sym].zero? ? m + v : (h[v.to_sym] -= 1; m) }
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement