Ad
  • Custom User Avatar

    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

    • the description should be updated to clearly state NON-NEGATIVE integers instead of positive, and to specify that only non-negative inputs will be used, or
    • the tests should be updated to correctly reflect the description and to more comprehensively test solutions
  • Custom User Avatar

    @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.

  • Custom User Avatar

    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?

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution