Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
I didn't know that cause that's not what you said in your comment. That's still slower for large number sizes, e.g 32 bit integers (the most common size for an integer in cpp), although if we're being specific since we're dealing with signed integers here, so the max would be like 2^31 - 1. I agree that for small numbers, the iterative method is faster, but not by much as both methods are practically instant when dealing with small numbers. It's better to make the function scalable to larger numbers by using this method.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
no, this solution about a lot of copiyng
too much copiyng
WTF
It's funny because this was actually pretty much my original answer, except that I didn't account for numbers less than zero.
The error message wasn't very helpful, so I found myself jumping through hoops trying to figure out how to handle floating point inaccuracies.
I feel smartn't seeing this
Seemed like a simple task, but I broke my head solving it, 2 out of 3 conditions in the task were met and the last one was not accepted by me. Of course, I had to resort to help....... It turned out to be the same thing I wrote, just with some minor changes, which also turned out to be tricky, but now I see that it's even easier. I'm going to be a wreck today, work in 4 hours and I haven't slept.....
Looks very simple, clear, and easy. Thank you! As for me: as always I created more complicated solution :)
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
std::map is actually O(logn) to find. A hashmap (std::unordered_map) would be what to use for efficiency
Fantastic. I was trying to create this simple O(n) O(n) solution. Only when you see it do you realise how simple it is. Kicking myself, as I was almost there twice but deleted and went down other avenues.
Great work.
Loading more items...