📌📌 C++ || Sorting || Two Pointers || Faster || Easy To Understand 🤷‍♂️🤷‍♂️
Sorting + Two Pointers\n\n Time Complexity :- O(NlogN)\n\n Space Complexity :- O(N)\n\n\nclass Solution {\npublic:\n    int numSubseq(vector<int>& nums, int tar
* ***Sorting + Two Pointers***\n\n* ***Time Complexity :- O(NlogN)***\n\n* ***Space Complexity :- O(N)***\n\n```\nclass Solution {\npublic:\n    int numSubseq(vector<int>& nums, int target) {\n        \n        int n = nums.size();\n        \n        long long mod = 1e9 + 7;\n        \n        // sort the nums\n        \n        sort(nums.begin(), nums.end());\n        \n        // precalculate the power and store in powers array\n        \n        vector<int> powers(n, 1);\n        \n        for(int i = 1; i < n; i++)\n        {\n            powers[i] = (powers[i - 1] % mod * 2 % mod) % mod;\n        }\n        \n        // apply two pointer approach and find possible result\n        \n        int i = 0, j = n - 1;\n        \n        int res = 0;\n        \n        while(i <= j)\n        {\n            if(nums[i] + nums[j] > target)\n            {\n                j--;\n            }\n            else\n            {\n                res = (res % mod + powers[j - i] % mod) % mod;\n                \n                i++;\n            }\n        }\n        \n        return res;\n    }\n};\n```
['Two Pointers', 'C', 'Sorting', 'C++']