FazeelUsmani / Amazon-SDE-Preparation

This repository includes all the interview preparation questions for Amazon SDE role
https://practice.geeksforgeeks.org/batch/Amazon-Test-Series
1.15k stars 295 forks source link

Create 08 positiveNegativePair.cpp #65

Closed Juro221 closed 3 years ago

Juro221 commented 3 years ago

We use unordered_map for hashing. We iterate once through our array of size N. If we find element that has not been seen yet, nor its opposite we increment value of this element in map. And we find the pair we increment their values in map to 2 and we push_back this pair in right order to our output. Time complexity is O(N).