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.
You also have O(n), if you want to find solutions with the best result, then there are other sites for this, where this is emphasized. Or you can post 2 solutions. One is short, the other is optimal.
For all arrays of type [0,0,0,1] you have the same result.
I don't think you'll get extra points for fast execution here.
SENSENEL, this is a very good question. Unfortunately, it is a brute force solution that is not optimal. See my solution which is 8 character longer (when removing spaces that were added for readability) but has an optimal O(n) time and O(n) space complexity.
I created a bechmark with a simple case, 1000 elements array, with no matching numbers (to test the worst-case scenerio of searching everything, instead of relying on luck to find the mathing numbers in first iterations). It compares my solution, Niksonman's solution and your solution: jsbench.me/23l4lcraig/1 - try changing the 1000 to million and see what happens.
@SENSENEL, you asked a very good question. In real recruitment tasks, the tests are more complex than here and also check the time and space complexity, so it is important to always keep it in mind. For example try how all of those solutions would pass the tests on AlgoExpert, which has exactly this task as its first task in their Easy list.
Same here - after attempting my first try from yesterday, just to see and analyse why those randos fail, it suddenly works!
OoooK ... ?
Maybe you guys check again - seems the author worked it out ...
Description should probably mention that array must be sorted in lexicographical order.
C++ translation
This comment is hidden because it contains spoiler information about the solution
Same for python
ok, this was kind of asking myself "in what way can those weird elements sorted?" Answer: Yes!
This comment is hidden because it contains spoiler information about the solution
Hello, if the "Gotcha" topic I mentioned doesn't trigger you, then it looks like you're not affected by it either.
Otherwise, I have described as briefly as I could what it is about.
For the rant in it i apologize again, but sometimes this must also be said
It seems to me that you have made an assumption that we know what you are talking about, but I should point out that's not the case. What exactly you want?
Just the other day I read here on Codewars from someone who complained about so-called "Gotcha" Katas.
This is one of them.
I am beginning to understand this very well!
Just, why??
Why can't you write in the description the actual, or better, the complete problem?
is this really such an uplifting "hihihihi" moment?
Why not put one of the more complex inputs - at least just ONE - in the test section too, rather than "Gotcha!" at Attempt first.
sry for the rant - have a nice weekend everyone!
definately not a 6kyu - if you compare solutions of this and other 6kyu's ...
Approved! ;)
Loading more items...