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 a return at every path. You can fix it by adding return 0; at the end of your function.
how can i fully understand a problem with my code if it doesn't show me the full vector?
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
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
Groovy Translation
Very clean solution!
If that's the last sample test, you probably deleted the 10 where there is no number there, backup your code, click Reset, and paste it again.
assert.strictEqual(findUniq([ 3, , 3, 3, 3 ]), 10);
why should this test case return 10???
im too slow how unfortuhnate
This issue is useless without mentioning which language is lacking this testcase. Closing.
Yes, if you do a 2-loop checking every combination possible... Though you can find more
O(NLogN)
andO(N)
solutions in the solution tab ^^Great Kata!
Can the solution have O(n²) time complexity?
Loading more items...