Follow up : Find the number of pairs in array whose sum>=x

Follow up : Find the number of pairs in array whose sum<=x

Expectation :

O(n) time and O(n) space ..

Followup : O(n) time and O(1) space .

Rules :

1)Explanation of algorithm in your answer is a must .

2)Writing code is optional .

3)If code is written , make sure to you use format option from the editor .