✅Easiest Basic C++ Solution | Using For Loop✅|100% Efficient
Solution :\n\nclass Solution {\npublic:\n    int countPairs(std::vector<int>& nums, int target) \n    {\n        int n = nums.size();\n        int count = 0;\n 
**Solution :**\n```\nclass Solution {\npublic:\n    int countPairs(std::vector<int>& nums, int target) \n    {\n        int n = nums.size();\n        int count = 0;\n        \n        for (size_t i = 0; i < n; i++) \n        {\n            for (size_t j = i + 1; j < n; j++) \n            {\n                if (nums[i] + nums[j] < target) \n                {\n                    count++;\n                }\n            }\n        }\n        \n        return count;\n    }\n};\n\n```\nExp: This code initializes the count to 0 and uses two nested loops to iterate through all pairs of indices (i, j). If the sum of nums[i] + nums[j] is less than the target, it increments the count. Finally, the count is returned as the result.\n\n\n\n\n
['Array', 'C', 'Sorting']