Ouch, that hurts
Very good remark, but everything is not so easy and depends entirely on data.
You can test it yourself, just imagine the list with 10 distinct values, each repeated 1000 times. It's much more easy to 'hashset' it in the start, then sort 10 values, then sorted 10000 values, and only then take only unique ones.
So, one more time, it depends on the data.
you should see what sagemath can do. I strongly recommend using sagemath as it is python 3 with a huge library of extra modules specifically for applied and abstract mathematics.
I think Arrays.stream() accepts array of objects no primitive array. isn't it ?
In Python 3, the result of the / operator (known as truediv) is a float, but the result of // (known as floordiv) is already an int and rounding it will have no effect.
I used the same code but to avoid floats I just,
I like your solution :-)
That's a catch for the case of null values. (incase when .isPresent() returns false)
orElse(0) which means?
Don't know why I didn't expect math to have a hypotenuse function. Should read the documentation.
Please, try to avoid loop inside loop if possible and in this task it is possible^)