From 03703d21782284f3227d259886239e0e28680e2b Mon Sep 17 00:00:00 2001 From: pratyush773 Date: Sat, 10 Feb 2018 13:28:54 +0530 Subject: [PATCH] Create TwoSum.cpp Cpp implementation of two sum --- .../src/com/alg/top20/adhoc/TwoSum.cpp | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 2018-feb/adhoc-thinking/src/com/alg/top20/adhoc/TwoSum.cpp diff --git a/2018-feb/adhoc-thinking/src/com/alg/top20/adhoc/TwoSum.cpp b/2018-feb/adhoc-thinking/src/com/alg/top20/adhoc/TwoSum.cpp new file mode 100644 index 0000000..3d6b3a3 --- /dev/null +++ b/2018-feb/adhoc-thinking/src/com/alg/top20/adhoc/TwoSum.cpp @@ -0,0 +1,55 @@ +#include +#include +#include +using namespace std; + +// sort and check adjacent element +int findDuplicate1(int arr[],int n){ + sort(arr,arr+n); + for(int i=1;i st; + st.insert(arr[0]); + for(int i=1;i>n; + int arr[n]; + int i; + + // generating a test case + for(i=0;i