JAVA/PYTHON SOLUTION || BEATS 100% || EASY TO UNDERSTAND || 2 POINTER
Approach\n Describe your approach to solving the problem. \nMake an array \'l\' of length n=length of nums,and insert 2^i in it, make sure that 2^i doest not ex
# Approach\n<!-- Describe your approach to solving the problem. -->\nMake an array \'l\' of length n=length of nums,and insert 2^i in it, make sure that 2^i doest not exceed 10^9+7.Now initialize two pointers left=0 and right=n-1 and check if sum of nums[left] and nums[right] is less than or equal to target or not. If it is less or equal, make count=l[right-left] and if it is greater than 10^9+7\nthen mod it and increment left. If sum is greater than target then decrement right.\n# Complexity\n- Time complexity: O(nlogn)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```java []\nclass Solution {\n    public int numSubseq(int[] nums, int target) {\n        int [] l=new int[nums.length];\n        Arrays.sort(nums);\n        l[0]=1;\n        int m=(int)1e9+7;\n        for(int i=1;i<nums.length;i++){\n            l[i]=(l[i-1]*2)%m;\n        }\n        int i=0,j=nums.length-1,c=0;\n        while(i<=j){\n            if(nums[i]+nums[j]>target){\n                j--;\n            }\n            else{\n                c+=l[j-i];\n                c%=m;\n                i++;\n            }\n        }\n        return c;\n    }\n}\n```\n```python []\nclass Solution:\n    def numSubseq(self, nums: List[int], target: int) -> int:\n        nums.sort()\n        l=[1]\n        m=int(1e9+7)\n        for i in range(1,len(nums)):\n            l.append((l[i-1]*2)%m)\n        i=0\n        j=len(nums)-1\n        c=0\n        while i<=j:\n            if nums[i]+nums[j]>target:\n                j-=1\n            else:\n                c+=l[j-i]\n                c%=m\n                i+=1\n        return c\n```\n
['Java']