From ce9c98eaf68c20bacd75cf6d5df8e6b8a9ec4867 Mon Sep 17 00:00:00 2001 From: Varun Goel <52860777+varungoel18@users.noreply.github.com> Date: Tue, 8 Feb 2022 11:29:57 +0530 Subject: [PATCH] pair sum of unsorted array --- Arrays/find_sum_pair.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Arrays/find_sum_pair.cpp diff --git a/Arrays/find_sum_pair.cpp b/Arrays/find_sum_pair.cpp new file mode 100644 index 0000000..860c204 --- /dev/null +++ b/Arrays/find_sum_pair.cpp @@ -0,0 +1,27 @@ +#include +#include +using namespace std; + +// in unsorted array + +int main () { + int arr[] = {2,3,1,6,5,4}; + int sum = 9; + int n = sizeof(arr)/sizeof(int); + int i = 0 , j=n-1; + sort(arr,arr+n); + while(isum) { + j--; + } + else if(arr[i]+ arr[j]