I don't think it can be done in O(n). Your own solution isn't either, it's O(n^2) just like this one. I think it can be done in O(n log n) or O(n*w) ( where w = bit width of n ), but no better.
People will vote lots of bad oneliners Clever and even Best Practice. (!!) indeed is a bad idea here, as it is almost always.
The duplicate kata has been retired.
Either way you'd have to loop through all digits, and
Counter
has at most ten keys.This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
I don't think it can be done in
O(n)
. Your own solution isn't either, it'sO(n^2)
just like this one. I think it can be done inO(n log n)
orO(n*w)
( where w = bit width of n ), but no better.People will vote lots of bad oneliners Clever and even Best Practice.
(!!)
indeed is a bad idea here, as it is almost always.Fixed.
Yep, full duplicate, I only pasted my solution with an extra '-s' for the function name and got it like clockwork...
Done. Is it good?
Random prediction
Yes, I was going to ask people that
Do you know how I could make them?
It is. A fix is available, but has to be approved by Raul.