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'm new to this section. Should I focus on improving code speed, or work on basic katas to build a strong foundation?
(Spoiler content – I’ll take care of that. I’m new, I’ll remember this, and it won’t happen again.)
if you faced struggles in the kata's explanation, inform the community for help!
challenging one, nice
Please don't post solutions in kata's discourse without marking your post as having spoiler content, even if they don't work, read this: https://docs.codewars.com/training/troubleshooting#post-discourse
About your problem, your code is too slow and does too many operations, that's why it times out. Nested loops, yes filter is a loop in disguise, won't work here.
This comment is hidden because it contains spoiler information about the solution
The Ruby version doesn't mention anything about sorting in the description, but the test cases fail if the parameters aren't in alphabetical order in the result.
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
Loading more items...