3 ms·
The "optimisation" of starting the inner loop at `j = i + 1` is done to avoid testing every pair of objects twice. [Ed: I should add that it also prevents test
by qwery 2y ago
The "optimisation" of starting the inner loop at `j = i + 1` is done to avoid testing every pair of objects twice.
[Ed: I should add that it also prevents testing an object against itself.]
The algorithm is O(n^2) because every pair will be checked once.