TWO POINTER APPROACH
\n# Code\n\nconst int MOD = 1000000007;\nclass Solution {\npublic:\n    int numSubseq(vector<int>& nums, int target) {\n        sort(nums.begin(), nums.end());\
\n# Code\n```\nconst int MOD = 1000000007;\nclass Solution {\npublic:\n    int numSubseq(vector<int>& nums, int target) {\n        sort(nums.begin(), nums.end());\n        int ans = 0;\n        int l = 0, r = nums.size() - 1;\n        \n        vector<int>p2(nums.size());\n        p2[0] = 1;\n        for(int i = 1; i < nums.size(); i++) {\n            p2[i] = (p2[i-1] * 2)%MOD;\n        }\n        while(l <= r) {\n            if(nums[l] + nums[r] <= target) {\n                ans += p2[r - l];\n                ans %= MOD;\n                l++;\n            } else {\n                r--;\n            }\n        }\n\n        return ans;\n    }\n};\n```
['C++']