paul Noel
asked on
I need to find all pairs in an array equal to a sum complexity 0(n) right away and in c++
the array has series of numbers Need to find all pairs in the array using a hash table
integers ...
integers ...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The question requires the following two items in identifying pairs of numbers that add up to a given SUM:
1) hash table
2) O(n) complexity.
The solution adheres to both of these requirements.
1) hash table
2) O(n) complexity.
The solution adheres to both of these requirements.
if you now have
Open in new window
where some of the series elements are arrays with size 2, you could create a second array only containing pointers to pairs like
Open in new window
but since you need to store the pointers it is not O(n).
Sara