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.
Not a "Best Practices" at all .
Complexity is O(n^2) .
Each time when I come here I am abused by these solutions, understanding that my brain is just confused unga bunga
This comment is hidden because it contains spoiler information about the solution
Seems not efficient
GG
This solution just seems to be running at a very high time complexity (O(n^2)), short though:)
Some tags moderation might be useful in this case ;)
This solution was submitted when a different compiler version and different library versions were used on Codewars. While the concept of modules is gradually introduced in C++, tradicional
include
s just insert contents of a file into another file. Since some files include other files and some files are included by the testing framework as well, lots of things end up declared in the scope transitively. Then if you rely on things being declared for you, it will break sometime or even already now with just a different compiler. Note thatbit/stdc++.h
isn't a part of any standard, so if you decide to use it, you should at least know what you're doing.Should be part of "algorithm" I think. Not sure how it used to work.
Just wondering but:
When I inserted this answer
into my editor, it came back in error.
I had to add #include<bit/stdc++.h> for 'count' to work.
I was wondering why the absence of include didn't effect this answer.
I am relatively new to C++ as most of my coding experience is in Java.
O(n^2)?
Bit late, I'm new to the platform. But basically what this solution is doing is iterating through the vector for every element in it and counting its occurrences, and returning it if the occurrence is odd. The reason why this solution "is terrible" is because it is an O(n^2) solution. Just because it takes one line of code to write doesn't mean it's efficient.
This is reading the vector numbers.size times! It doesn't seem a good idea..
True, but the fact that so many think this is "best practice" is... awkward.
Let's keep in mind that the purpose of this place is to learn. Obviously people won't post perfect solutions but the important thing is to learn from mistakes and improve together.
Loading more items...