Java two pointer with explanation
\nclass Solution {\n    public int numSubseq(int[] nums, int target) {\n        Arrays.sort(nums);    //Sorting so that we can get the min and max directly\n   
```\nclass Solution {\n    public int numSubseq(int[] nums, int target) {\n        Arrays.sort(nums);    //Sorting so that we can get the min and max directly\n        int i=0,j=nums.length-1,count=0,mod=(int)1e9 + 7;\n        int[] power=new int[nums.length];  //Calculating the power in the power array.\n        power[0]=1; // no. of subsequences formed using one no. is 1\n        for(int idx=1;idx<nums.length;idx++)\n            power[idx]=(power[idx-1]*2)%mod;  \n\t\t\t//Now if i is at 0 and j is at 3 then the no. of \n\t\t\t//subsequences keeping the first no. that is at i fixed we can form 8 subsequences, similarly for different values of i and j the no. of subsequences varies.\n\t\t\t// if this is the array\n\t\t   // 3 5 6 7\t\t\t\n\t\t   // i     j                      j-i=3.\n\t\t   // then no. of subsequences formed keeping 3 constant is 8 which is stored in the power array (power[j-i]=8) just do a dry run of the formula. you will get 8 for gap of 3\n\t\t\t//3\n\t\t\t//3 5 6 7\n\t\t\t//3 5 6\n\t\t\t//3 5 7\n\t\t\t//3 6 7\n\t\t\t//3 5\n\t\t\t//3 6\n\t\t\t//3 7\n        while(i<=j){\n            if(nums[i]+nums[j]<=target){\n                count=(count+power[j-i])%mod;\n                i++;\n            }else if(nums[i]+nums[j]>target)\n                j--;\n        }\n        return count;\n    }\n}\n```
['Two Pointers', 'Java']