Sorting + Two Pointers technique || Simple And Easy C++ Solution ||
Intuition\nwe can apply two sum problem logic here for solving it.\n# Approach\n Describe your approach to solving the problem. \nsort the array and apply twosu
# Intuition\nwe can apply two sum problem logic here for solving it.\n# Approach\n<!-- Describe your approach to solving the problem. -->\nsort the array and apply twosum problem  logic \nthe number of subsequences will be pow(2,subsequence length).\n# Complexity\n- Time complexity:\nO(NLOGN)\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int numSubseq(vector<int>& nums, int x) {\n        int mod=1e9+7;\n        int n=nums.size();\n                vector<int>pow2(n+1,1);\n   //instead of using inbulit function precomputing all powers of 2 upto n\n        for(int i=1;i<=n;i++)\n        {\n            pow2[i]=pow2[i-1]*2%mod;\n        }\n      //sort the array\n         sort(nums.begin(),nums.end());\n         long long ans=0;\n    //apply two sum logic\n                   int i=0,j=n-1;\n                  while(i<=j)\n                  {\n                      if((nums[i]+nums[j])<=x)\n                      {\n                         \n                     ans=(ans+(pow2[j-i]%mod)%mod)%mod;\n                       \n                            \n                          \n                          i++;\n                      }\n                      else j--;\n                  }\n                  return ans;\n            }\n};\n```
['Two Pointers', 'Sorting', 'C++']