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.
It is theoretically possible that your code will go through your function without doing any
return
, and C++ does not like this. It is not possible in this challenge because all inputs are guaranteed to have a valid answer, but C++ compiler does not know this, and it needs to have areturn
at every path. You can fix it by addingreturn 0;
at the end of your function.You can use
std::cout
in your solution and print the vector to the console, but I agree this can be tedious in C++. Ideally, tests would show the vector, but they don't.But even when you add missing
return
, and when you check the vector, and you will try to reproduce the error, it is possible that your code will work for you. The bug in your code can be subtle and difficult to debug, and it's caused by out of bounds access: sometimes, your code accesses invalid memory before the vector, and sometimes after the vector, and this can be a bug difficult to reproduce.I don't understand what it wants from me??? ./solution.cpp:10:1: warning: control may reach end of non-void function [-Wreturn-type]. And next question - how can i fully understand a problem with my code if it doesn't show me the full vector? Wrong answer for 5 elements!
Expected: equal to 0.55
Actual: 1