Please help me solve this problem using binary search.I am not able to figure out my mistake
hello @shresth_2000
ur implemention is not correct.
the idea is to first sort the array.
then iterate from start i,e i=0 to i=n-1.
and consider a[i] as one of the element of the pair and then use binary search in range ( i+1…n-1) to find other element .
for i -> [0 .....n-1]
int key=target-a[i]
binarysearch(key, i+1,n-1)
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.