Easy C++ | O(NlogN) Solution
We can use a set and get the count how many numbers can form the pair which is the count of numbers that are <= target-nums[i]\n\nComplexity -> O(nlogn)\n\n\ncl
We can use a set and get the count how many numbers can form the pair which is the `count of numbers that are <= target-nums[i]`\n\nComplexity -> O(nlogn)\n\n```\nclass Solution {\npublic:\n    int countPairs(vector<int>& nums, int target) {\n        int cnt = 0 ;\n        int n = nums.size();\n        multiset<int>st ;\n        for(int i = 0 ; i < n ;i++){\n            auto pos = st.lower_bound(target-nums[i]);\n            cnt += distance(st.begin(),pos);\n            st.insert(nums[i]);\n        }\n        return cnt ;\n    }\n};\n```
['C']