best solution for this problem  in c++ :
\n\n# Complexity\n- Time complexity:\nO(N^2)\n\n- Space complexity:\nO(1)\n\n# Code\n\nclass Solution {\npublic:\n    int countPairs(vector<int>& nums, int targ
\n\n# Complexity\n- Time complexity:\nO(N^2)\n\n- Space complexity:\nO(1)\n\n# Code\n```\nclass Solution {\npublic:\n    int countPairs(vector<int>& nums, int target) {\n        int n = nums.size();\n        int ans = 0;\n        for(int i = 0 ; i < n ; i++){\n            for(int j = i + 1 ; j < n ; j++){\n                if(nums[i] + nums[j] < target)\n                    ans++;\n            }\n        }\n        return ans;\n    }\n};\n```
['C++']