Pair Sum

Revision en1, by Expose, 2023-10-11 18:02:45

Recently I have a problem ..How can I count the number of pair who's sum lies between a given range a and b in a vector?? Suppose I have vector is 5 1 2 and the a =4 and b =6 output will be 2 cause 5+1=6 and 1+2 =3 but 5+2=7 which is not be included..So the output should be 2 ,How to solve it in a optimal way?

Tags sum

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English Expose 2023-10-11 18:02:45 322 Initial revision (published)