Skip to content
This repository was archived by the owner on Dec 12, 2023. It is now read-only.

Conversation

stezu
Copy link
Contributor

@stezu stezu commented Mar 6, 2015

The previous solution didn’t allow for duplicate results so it didn’t
work as expected by the second test. This solution works with both
tests and does so very quickly at ~1.4M ops/sec
(http://jsperf.com/array-pair-sums).

The previous solution didn’t allow for duplicate results so it didn’t
work as expected by the second test. This solution works with both
tests and does so very quickly at ~1.4M ops/sec
(http://jsperf.com/array-pair-sums).
@blakeembrey
Copy link
Owner

Hi @stezu, I actually think the readme example is wrong since I remember spending a bunch of time perfecting not outputting duplicate elements 😛

Source: https://github.com/blakeembrey/code-problems/tree/master/problems/array-pair-sum

@stezu
Copy link
Contributor Author

stezu commented Mar 6, 2015

The expected result of the second test is going to be [ [3, 5], [4, 4] ] then right?. In that case, neither of our solutions work. :P

@blakeembrey
Copy link
Owner

It should be just [[3, 5]]. But we should update the example to match the description.

blakeembrey added a commit that referenced this pull request Aug 11, 2015
Add tests for array pair sum and a working solution.
@blakeembrey blakeembrey merged commit f4d3f95 into blakeembrey:master Aug 11, 2015
@blakeembrey
Copy link
Owner

I've merged but I'm going to refactor as your solution is also O(n^2) regardless of being right/wrong according to the README.

Edit: Sorry, zoned out then. It's O(log * n).

blakeembrey added a commit that referenced this pull request Dec 21, 2015
Add tests for array pair sum and a working solution.
blakeembrey added a commit that referenced this pull request Sep 29, 2017
Add tests for array pair sum and a working solution.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants