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.
per the description your code must handle empty vectors and return
0
in that case; but your code crashes because in the loopyou dereference an empty vector, which is undefined behavior.
Please ask
questions
to ask for help in the future, anissue
is a provable flaw in the kata ;-)Would you please paste your code properly formatted?
Just run your code and indeed it's just too slow. You'd have to find some more performant algorithm.
It would be also helpful if you used proper code formatting when posting code blocks :)
Resolving as not a kata issue.
I didnt have a chance to run your code, but just reading it it seems to have insufficient time complexity and is most probably too slow.
Expected approach is O(n) in time, and O(1) in space, while your solution seems to be O(n^2) in time and O(n) in space.
Yes, it's a problem with your code, not a kata issue, the expected result is fine.
Print the expression too, otherwise how could we know if the problem is in the kata or in your code?
It isn't removed at all, it's not removed because it doesn't appear more than 2 times.