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.
The description asks for the sum of the two lowest positive integers, but
a) the function signature uses int not unsigned int, implying that negative numbers are valid inputs
b) despite this, none of the tests make use of negative numbers, meaning that as of now many of the accepted solutions may not actually be solutions to the problem as stated
c) however, the tests DO make use of zero, which is not a positive number, meaning that some solutions which DO solve the problem as stated may be rejected by the current test
Either
@Dentzil going to have to hard disagree. It does not take a very large input at all before O(n) is significantly more performant than O(nlogn). Not only this, but as umetnik demonstrates it can be done easily in exactly the same number of lines using a different already-existing STL function! Is that really less readable?
As a matter of principle you should never sort an input from which you really only want the first or last n elements. This solution is very easy to understand, you are right, but it is NOT best practice IMO.
Could you explain in this instance, is there a benefit to making the strings in your lambda function const& strings, instead of just saying std::string s1?
This comment is hidden because it contains spoiler information about the solution