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 think that this solution is the easy one :)
Considering the return type is
unsigned int
, you should use anunsigned int
for the running sum, as it (normally) has a greater range of values thanint
. 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 inunsigned int
.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
andsecond
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).Can somebody explain this ???