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.
I literally made sure, that it does check for multiple values in a really efficient manner, then realized it's only for 2 values in total.
Wish I realized earlier...
Take a pen and a paper and try to figure out what's going on. The code is right, at some point you're missing something.
But what happens if n[0] is repeated again in n[3]? This could wouldn't run further after it encouters the "return" statement right?
It seems to me that this solution is incorrect, since it assumes that the unique element is positioned at index 0 of arr?
awsum
I guess that settles this issue...
Oh I misread your comment actually. I cannot have a well founded opinion about the issue raised since I have not solved the kata.
Yes, I understand your comment, but this evidently does not apply here, because old solutions still pass in all language versions. An they pass by a wide margin. Less than 9000ms is well below th cut-off
I haven't solved the kata so I cannot say much. This is a recurring problem with performance katas, they can be closely dependent on the language version and any update can mess it up. This is not fair however, and ideally the tests should be adjusted when a new update creates important performance disparities like apparently here.
As a quick first test I ran a few of the most recent accepted solutions and oldest solutions (see below) using Node v14.x (results for other nodes in parentheses). Indeed, some of the recent solutions time out. Maybe they passed with older nodes, but I tested that for only one. The three oldest solutions all pass consistently by a wide margin. There is some significant variation in time for subsequent attempts, possibly connected to server load. I ran these tests on a Saturday afternoon European time.
Conclusion, the kata still works. It is not enough to have just any logarithmic complexity algorithm. Also the code needs to be performance optimised. This is possible: monadius' solution is on average 15% faster than my initial solution.
I hope that helps. Good luck!
recent sollutions:
old solutions:
Of course, thanks for looking into it!
Let me know if I can be of any help by providing more details.
I'll look into that. Just give me few days, I am a bit on a tight schedule at the moment.
This comment is hidden because it contains spoiler information about the solution
First of all: I absolutely love this kata. On the surface it seems so simple... but its surface conceals many, hidden complexities. Thank you @zappa78!
Unfortunately I also feel something is wrong with the Javascript variant, just like @zhirnov-d and @Iluxmas remarked 4 days and 17 days ago. Perhaps due to an update, as @Iluxmas suggested?
I have written quite a performant algorithm (tests complete in 733ms, that's even about 16 times faster than @Iluxmas), but still I get remote timeouts. While remotely all '10000 big numbers' and all '100000 big numbers' pass, the final category '1000000 big numbers' times out.
I came to believe that something is wrong because of three reasons:
What do you think of this, @zappa78?
I will try to share my solution in a comment to myself, so that I can set a spoiler flag.
Should rather say that the horizon is the limit, eh?
Loading more items...