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're welcome! 🙌
nice solution. readable. easy to understand among all the other recursive solution here. i will keep this in mind. thanks for this.
i like your solution better than mine. readable and logic is straight forward. very easy to understand.
hi PdoubleU, time complexity of this solution is quadratic. indexOf is a loop and it is inside a filter function which is another loop.
totally agree. maybe clever but confusing as hell. readable code over clever code. always.
this can be done in one pass. linear time. splicing and pushing to the end is no longer linear time because splicing and re-indexing the array is like an inner loop within the for-loop, making the time complexity quadratic.