Blog on algorithms, puzzles, programming .... musings of a computer engineer.
Several solutions are possible:1. Sort the array in O(n log(n))2. Use an STL hash_set, or an bucket (only if the numbers fall with in a known range), and then the solution can be arrived in O(n) time (2 pass algorithm)
Post a Comment
1 comment:
Several solutions are possible:
1. Sort the array in O(n log(n))
2. Use an STL hash_set, or an bucket (only if the numbers fall with in a known range), and then the solution can be arrived in O(n) time (2 pass algorithm)
Post a Comment