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.
Cool!
I did O(n^2) and got timed out. what's wrong with mine?
You're doing a large amount of unncessary work. Your logic is on the correct path, but you need to avoid going over all the numbers.
Merged.
what would be the point of that ? your code is much longer and more cumbersome to write than a legitimate solution.
A little rough to say I "ruined" it with performance, don't ya think?
That said, I see including a large data parsing requirement as similar to the difference between someone solving a software problem for a small local business versus a Fortune 500 company. Being able to code solutions for data at scale can make a huge difference in someones paygrade.
The lists in this case could have 10000 elements, so printing them would be too verbose.
https://docs.codewars.com/training/troubleshooting#print-input
If you're looking for the version where O(n) is expected, it's this kata.
You can start by really reading into the description :D
I saw it. My point was that the tests passed the right arrays, and expected results were correct, so the issue wasn't with the kata itself. I agree that every
var
should be replaced withconst / let
but that's a minor issue (especially considering that the kata is in beta for 7 or so years).I'm not an oracle, so I don't know. Global variables? Confusion?
You can always go to Solutions tab and fork any solution, and play around with it. You can modify tests as you see fit (you will notice that adding
const
doesn't change anything). Tests pass a copy of the array, so the expected result isn't affected by your code.See above. I marked it as spoiler just in case. The "issue" seems to come from your code.
This comment is hidden because it contains spoiler information about the solution
Loading more items...