i have done the question using sorting and then two pointer technique.but couldnt think how to do it using D & C app
Need the code logic for D & C approach
hello @techashish2000
a) sort the array.
b) then for i -> 0 to n-1 check whether target-a[i] is present or not in the right side of index i. (u can use binary search to find this)
c) if exist then update ur answer otherwise move to next
yeah binary search is what i am asking
please give approach for binary search
i have already given.
check point b.
in point b u need to search for target-a[i] in range [i+1 …n-1] so just apply binary serach in this range to check whether it is present or not.