Perfect solution with Perfect explanation [ACCEPTED]
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(nlogn)- for sorting the list\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n\n# Code\n```\nclass Solution:\n    def countPairs(self, nums: List[int], target: int) -> int:\n        nums.sort()\n        l, r  = 0, len(nums)-1\n        result = 0 \n\n        while l< r:  \n            if nums[l] + nums[r] < target: \n                # this assumes that if the sum of the element at position l and the one in at position r \n                # is less than target since the list is sorted we can for sure say that the sum of the element \n                # at the position l and those below between position l and and r is less than target \n                # meaning we can pairup element at pos l with other elements below and including the one at\n                # position r hence  ans += r-l and we increment l since we are done with the current one. \n                result += r-l    \n                l += 1 \n            else: # if the sum is greater or equal to target just decrement r \n                r -= 1\n\n        return result \n\n        \n\n\n\n       \n        \n```
['Python3']