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.
The .up and .down inline conditionals seem to be redundant
not sure if recursion is the best approach here, since you do
abs
each time, although it will be a valid value after the first executionWhile this is a simple solution, it has complexity of
O(n log n)
; For big arrays it could be suboptimal if the first first element ofa
didn't have a match (no early return) or ifb
was an empty array