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.
Metrics
There are 2 functions in this file.
Function with the largest signature take 2 arguments, while the median is 1.5.
Largest function has 1 statements in it, while the median is 0.5.
The most complex function has a cyclomatic complexity value of 2 while the median is 1.5.
////////////////////////////////////////
I took from https://jshint.com/
in my opinion complexity 2 is quite good;
You're welcome! It was a great idea for a kumite, so thank you for contributing the original idea.
I've made a fork of the original solution, but with a range of tests for speed checking. I've included the speed of everyone's solutions in the comments of that fork.
Sorting is not helping a single bit here. In the worst case scenario, you'd receive an array consisting only of positive/negative numbers (except one if a pair is guaranteed to exist) and still make
n^2
lookups. The only way to achieve what you want is to filter positive and negative values into 2 separate arrays and performm * (n - m)
lookups instead.Sorting is a very expensive though, because of the large amount of operations required to change the array.
Ideally we need a large amount of test cases, with a range of values. Then we could do a speed comparison.
There's no point in sorting if you're not using binary search.
in case or more data like this
[3, 6, -8, -2, 4, 5, -1, 8, 1] => I have 2 pairs [-8,8] and [-1, 1]; what will be result in my example?
I am trying to see the big picture.
From the original kumite description.
hey Remo,
I think I get better understanting.
What will happen in case of
[3, 6, -8, -2, 4, 5, -1, 8, 1] what will be the return?