this is one of two pointers question of leetcode.
i am getting run time error in some of the testcases due to the large input can you explain how to overcome those??
here is the code
int numSubseq(vector& nums, int target) {
int n=nums.size();
if(n==1 || n==0)
{
return 0;
}
int r=n-1;
sort(nums.begin(),nums.end());
int i=0;
long long int res=0;
while(i<=r)
{
int left=nums[i];
while(left+nums[r]>target)
{
r-=1;
}
res+=(pow(2,r-i));
i++;
res%=1000000007;
}
return res;
}
};