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 = s.chars
- o = []
- s.each do |v|
- if h[v.to_sym] > 0
- h[v.to_sym] -= 1
- else
- o << v
- end
- end
- o.join
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement