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.
"Most applications" is a very subjective phrase. I agree many premature optimizations are evil, but why waste time when the optimization is more like a logical solution than a weird tweak to match certain environment? FYI this solution takes around 500ms for 1 million. Not a huge number in the computer world I would say.
I don't think there's any way to do this in constant time because you're asked to generate a list of m numbers up to an input n. You could absolutely do better than the
filter
/reduce
combo, but I think this gets points for readability.At present, this has
mn
time, wheren
is the input andm
is the number of items that match the criteria of being divisible by both 3 and 5. For most applications, the optimization ton
time isn't worth it.