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.
This is an amazing approach!
Just to improve it even more, you all can use std::partial_sort to just sort a certain number of elements.
Like, std::partial_sort(ages.begin(), ages.begin()+2, ages.end(), std::greater{}); this line with just sort 2 elements, the two greater elements actually.
And that would sort only two elements leaving the others disordered.
If you're doing some challenges in c++ in this website, I recommend you all to visit https://en.cppreference.com/w/cpp/algorithm
There are a bunch of useful functions and classes there (but somewhat complicated to actually use correctly).
I did it in c++ because I gave up in C.
In C you can't just concatenate that way as you said, this is a really weird challenge.
Like always, learning new things in codewars.
I didn't know about the existence of the object "Set".
I knew about Regex but I didn't know how to apply all of this together.
So I did it manually, with hashtables.
In the first tests, there are actually more than one case in a single TestCase, just for you to know.
They should actually be separated into more than one TestCase but they're in the same one, so just to keep in mind
if you wanted to test returning true and then false.
This comment is hidden because it contains spoiler information about the solution
That is true, I actually looked for an Idea (somehow I tried the most upvoted answer but for some reason, my counter didn't increased/decreased, idk why honestly lol)
But anyways, after trying, I looked for some answer and found the same problem but more complex (with other kind of braces) and it was cool, seeing the same problem but with a stack.
I came out with this kind of algorithm (just using functions to not lose my mind).
Honestly, I can't come out with LINQ for now, it's really weird for me...
I'll keep practicing LINQ but for now, I'll prefer the old "for" and "foreach" loops.
It really is, the input is an int.
If they ever change it do double, that's the work of the one who made it double.
but for an int input, it is the best practice so far.
The numbers were generated with a past algorithm for sure.
But then the results were used for this one.