Ad
  • Custom User Avatar

    Considering the return type is unsigned int, you should use an unsigned int for the running sum, as it (normally) has a greater range of values than int. And signed integer overflow is undefined behavior. Unsigned integer overflow isn't - you could safely overflow and underflow and still arrive at the correct answer as long as it fits in unsigned int.

  • Custom User Avatar

    https://stackoverflow.com/a/10758845/12509349

    The top answer does a very nice job of breaking down many different ways to print out the contents of a vector, which is very very similar to the problem in the Kata. While reading this, note that all the different techniques are supposed to do the same thing.

    first and second are key terms in C++ which reference the first and second items in a pair. These are also used for the key and value of a map (dictionary).

  • Default User Avatar

    Can somebody explain this ???