At the time of compiling this code, the result is okay but while submitting this code I get Runtime error[Segmentation Fault (SIGSEGV)]. Why do i get Runtime error? Could anyone explain it? Below is the code snippet.
Use Binary Search after sorting. Search for
(X-a[i]) in the sequence for every
i. Hope this helps.
Thanks a lot. Finally i’ve solved it.
You can also use multiset to search for (x-a[i]) in the array .This will also take (n*logn) time