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've never seen
decltype
before. looks coolTrue
I didn't see that
But I did improve on the one i forked.
The check for size == 0 is redundant. If the size is zero std::accumulate returns 0 anyway.
I think returning -1 isn't a good practice anymore. In general use std::optional for that.
In this case returning -1 is simply wrong! the sum of an empty vector just isn't -1, also suppose the vector was { 1, 1, -3 } then it's sum would also be -1.
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 check for -ve?
.
Your solution has a very, very serious performance problem. Testing a single value of
2_000_000_000
makes it time out. Yourfor
loop needs fixing, because the way it is now, it works terribly slowly.I would consider a solution which loops a billion times buggy, and not a kata issue.
This comment is hidden because it contains spoiler information about the solution
Why is this a kata issue? Maybe your solution is too slow or falls into some infinite loop?
execution always times out, please help!
(objective-C).