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?
Thank you vary much one more time! Its really great kata. In the begin I don
t understadt what you wont. But now I made solution I have little bit more exp. and skill
s in the write codding!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.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Yes, it's a problem with your code, not a kata issue, the expected result is fine.
Expression: -68--87+-15+22*-72*-42+12+90;
=227956
227956
Expected: equal to 66634 (+/- 1e-06)
Actual: 227956
Seems to be something wrong on my side.
Print the expression too, otherwise how could we know if the problem is in the kata or in your code?
I passed all default tests and always get red in once random test witch is:
Expected: equal to -117.98 (+/- 1e-06)
Actual: 21.1695
and always get different expected value in test. Does it precission of floating point problem ? In my code I use double for storing numbers.
There is probably error in test cases in cpp version in the last example.
It isn't removed at all, it's not removed because it doesn't appear more than 2 times.
This comment is hidden because it contains spoiler information about the solution
Can you check the fixed and edge assertion especially that below. (in C++ example). I supposed there is an error. Or can you rewrite test as test in main function.
should_pass_all_fixed_and_edge_assertions
Expected: equal to {pos = {2}, peaks = {3}}
Actual: {pos = {2, 4}, peaks = {3, 2}}