Ad
  • Custom User Avatar

    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).

  • Custom User Avatar

    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.

  • Custom User Avatar

    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.

  • Custom User Avatar

    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.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    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.

  • Custom User Avatar

    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.

  • Custom User Avatar

    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.