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.
Is modifying the input really best practice?
1
5 yo , but anyway .
Vectors have a reserve member function .
So , even little ineficient can be removed ... with the right situation for reserve of course :)
i don t think so,as long as the code is very efficient(like this one) i don t think readability really matters,you can just put the code in a function and call it whenever you need it,so readability won t be a problem,unless you have to debug of course😂
bad practice for industry code. Code have to be simple to read and understand.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
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).genial
Can somebody explain this ???