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.
wrong in this case. all elements are identical except one. there aren't a lot of swaps going on. what are you talking about.
Sorting is efficient when the input data is small. For large data set would be efficient.
I agree with the previous commentator, I forgot about sets and sorting)).
I consider this solution to be the most understandable and concise than the solution at the top of the list. The only question regarding the speed of code execution is - what will be faster, sorting or converting to a set?
I completely forgot about the sorting methods and my code is hella complex but atleast it works.
@mediocreprogrammer99 & @RamidW
you should use always the spoiler flag when discussing code
(i added the flags to your comments)
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Your's is probably a bit faster without the need to copy the list. I tend to not modify the data I'm given just in case the test cases are written in such a way as to depend on the same data after my function is called (it's bitten me in the past).
ditto
try this to measure time :
I did it on the solution that I implemented (based on a sort) and found it OK in performance compared to other solutions.
For ex on a 1-million items list: time to execute with sort = 3 ms, time to execute with solution with sets = 8 ms
for whatever that's worth ...
tried the same way but had a memory limit with sorted a very big numbers array.
pass with count el of sorted set
This comment is hidden because it contains spoiler information about the solution
The time complexity of sorting is very high
What if [1,2,2,2,2], then this solution should now work
damn it! it's great!
Loading more items...