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/

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.

in worst case scenariou you would go only through half of the numbers

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 perform m * (n - m) lookups instead.

true, but, if you sort the numbers, in worst case scenariou you would go only through half of the numbers.
Without sorting in worst case you would have to go through all of them.

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.

That's a part of the exercise.

ordered - suppose to have unique values

for this code:

Metrics

There is only one function in this file.

It takes one argument.

This function contains only one statement.

## Cyclomatic complexity number for this function is 3.

https://jshint.com/

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;

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 perform`m * (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.

true, but, if you sort the numbers, in worst case scenariou you would go only through half of the numbers.

Without sorting in worst case you would have to go through all of them.

Please correct me if I'm wrong

There's no point in sorting if you're not using binary search.

nothing really, the case imply that there is n negative and n positive numbers with just one pair.

thats why optimization is the key

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?

Replacing a loop with a higher order function is not improving it.

Hey Crisan,

there should be only one pair in the array.

Also what if array has 1000+ ints in it?

## Loading more items...