Java | Python | C++ | Two-Pointer
\nclass Solution\n{\n    public:\n        int numSubseq(vector<int> &nums, int target)\n        {\n            int n=nums.size();\n            sort(nums.begin()
```\nclass Solution\n{\n    public:\n        int numSubseq(vector<int> &nums, int target)\n        {\n            int n=nums.size();\n            sort(nums.begin(), nums.end());\n            int l = 0;\n            int r = n - 1;\n            int ans = 0;\n            int mod = 1e9 + 7;\n\n            vector<int> pow(n, 1);\n\n            for (int i = 1; i < n; i++)\n            {\n                pow[i] = (pow[i - 1] *2) % mod;\n            }\n\n            while (l <= r)\n            {\n                if (nums[l] + nums[r] > target)\n                {\n                    r--;\n                }\n                else\n                {\n                    ans = (ans + pow[r - l]) % mod;\n                    l++;\n                }\n            }\n\n            return ans;\n        }\n};\n```\n```\nclass Solution {\n    public int numSubseq(int[] nums, int target) {\n        int n = nums.length;\n        Arrays.sort(nums);\n        int l = 0;\n        int r = n - 1;\n        int ans = 0;\n        int mod = 1000000007;\n        \n        int[] pow = new int[n];\n        pow[0] = 1;\n        for (int i = 1; i < n; i++) {\n            pow[i] = (pow[i - 1] * 2) % mod;\n        }\n        \n        while (l <= r) {\n            if (nums[l] + nums[r] > target) {\n                r--;\n            } else {\n                ans = (ans + pow[r - l]) % mod;\n                l++;\n            }\n        }\n        \n        return ans;\n    }\n}\n```\n```\nclass Solution:\n    def numSubseq(self, nums: List[int], target: int) -> int:\n        n = len(nums)\n        nums.sort()\n        l = 0\n        r = n - 1\n        ans = 0\n        mod = int(1e9) + 7\n        \n        pow = [1] * n\n        for i in range(1, n):\n            pow[i] = (pow[i - 1] * 2) % mod\n        \n        while l <= r:\n            if nums[l] + nums[r] > target:\n                r -= 1\n            else:\n                ans = (ans + pow[r - l]) % mod\n                l += 1\n        \n        return ans\n```
['Two Pointers', 'C', 'Python', 'Java']