Easy Java Solution || Using Two Pointers
\n\nimport java.util.*;\n\nclass Solution {\n    public int countPairs(List<Integer> nums, int target) {\n        Collections.sort(nums); // Sort the list in as
\n```\nimport java.util.*;\n\nclass Solution {\n    public int countPairs(List<Integer> nums, int target) {\n        Collections.sort(nums); // Sort the list in ascending order\n        int cnt = 0;\n        int left = 0;\n        int right = nums.size() - 1;\n        \n        while (left < right) {\n            int sum = nums.get(left) + nums.get(right);\n            if (sum < target) {\n                // If the sum is less than the target, all pairs between left and right will also be less than the target\n                cnt += (right - left);\n                left++;\n            } else {\n                // If the sum is greater or equal to the target, move the right pointer to the left\n                right--;\n            }\n        }\n        \n        return cnt;\n    }\n}\n\n```
['Java']