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.12k stars 291 forks source link

Create 03 twoSum.cpp #70

Closed Juro221 closed 3 years ago

Juro221 commented 3 years ago

We simply iterate through an array of size N. If X-arr[i] is not in unordered set we insert arr[i] to set and if we find some element in set with this approach, it means that we found 2 elements which sum is X. Time complexity : O(n)