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 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.Not a fan of the trailing closure mid-expression -- but otherwise identical to my solution 👌🏽