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.
You're doing
reduce(...) // reduce(...) for i in range(...)
, that's a nested loop, henceO(n^2)
.You should post your solution in a comment so it could be reviewed. Maybe you're missing something, and your algorithm is not actually linear.
Your second approach is correct, but the overall algorithm is bad. You have to make it fully linear.