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.
best one so far. genius!
This comment is hidden because it contains spoiler information about the solution
solution is simple, but bad perfomance as well as with map() instead of .find().
This solution is simple but in performance is bad
Number of operations in the inner loop does not depend on
n
, so it's not going to be O(n^2). As you noticed, inner loop always performs a limited number of operations (two or three, if I count correctly, except a single iteration when the unique number is encountered), and only the outer loop executesn
times.The complexity would be O(n), or very close to it, but still with unnecessarily high constant factor.
Question for anybody who's more knowledgable than me, would this actually be a quadratic solution? I mean given the constraints of the input array wouldn't indexOf and lastIndexOf only need one operation every time except once because the index of the current element will usually be at the first and last element. I mean I'm assuming they start searching their respectively under the hood. When n is the actual unique value then it's a linear operation, but that would make this solution O(2n)? because it's only another linear operation once?
this is unnecessarily complex in temrs of Big-O.
This is indded a clever solution, however the time complexity is O(n^2) and makes it less performant.
This comment is hidden because it contains spoiler information about the solution
Great solution!
this is amazing actually
I think it's the best.
This comment is hidden because it contains spoiler information about the solution
This code should rank number 1 by 'Best Pratice' and by 'Cleverness'
I have learned through research from what I saw in this answer
Loading more items...