Given a list of integers nums and target, return the number of pairs (i, j) with i < j such that nums[i] + nums[j] < target.
Sort the array. Use two pointers. If sum < target, all pairs (lo, lo+1..hi) are valid. Count them and advance lo.
- Sort nums. lo=0, hi=n-1, count=0.
- If nums[lo]+nums[hi] < target: count += hi-lo (all pairs with lo are valid), lo++.
- Else: hi-- (sum too large).
- Time Complexity: O(N log N)
- Space Complexity: O(1)