Java 27 ms Faster than 99.87% online submissions using sliding window and Sorting
\nclass Solution {\n    public int numSubseq(int[] nums, int target) {\n        final int MODULO = 1000000007;\n        int length=nums.length;\n        Arrays.
```\nclass Solution {\n    public int numSubseq(int[] nums, int target) {\n        final int MODULO = 1000000007;\n        int length=nums.length;\n        Arrays.sort(nums);\n        int[] power2 = new int[length + 1];\n        power2[0] = 1;\n        for (int i = 1; i <= length; i++)\n            power2[i] = (power2[i - 1] * 2) % MODULO;\n        int l=0; int r=length-1; int ans=0;\n        while(l<=r){\n            if(nums[l]+nums[r]<=target){\n                ans=(ans+power2[r-l])%MODULO;\n                l+=1;\n            }else{\n                r-=1;\n            }\n        }\n       \n        return ans;\n    }\n}\n```\n//this question in java can work with Math.pow function also but Math.pow returns double value and then that gets converted to int thus deviates the value of ans ...and so power2 is pre-computed in here\n```
['Sliding Window', 'Sorting', 'Java']