optimized || binary search || explained
To maximise the length we need to include the maximum elements is our solutiuon.\nTo do so we need to pick the samlalest elements first.\nSo, we can sort the ar
To maximise the length we need to include the maximum elements is our solutiuon.\nTo do so we need to pick the samlalest elements first.\nSo, we can sort the array to do so.\nAnd for searching the querie target sum we can perform binary search on the cumulative sum of sorted array.\n\nTime Complexity : O nlogn\n\n***CODE***\n```\n# binary search function \ndef solve(s,target):\n        l,h=0,len(s)-1\n        ans=-1\n        while l<=h:\n            mid=(l+h)//2\n            if s[mid]==target:\n                return mid+1\n            elif s[mid]>target:\n                ans=mid\n                h=mid-1\n            else:\n                l=mid+1\n        return len(s) if ans==-1 else ans\n        \n    s=[]\n    nums.sort()\n\t#calculating cumulative sum of sorted array \n    s.append(nums[0])\n    for i in range(1,len(nums)):\n        s.append(nums[i]+s[-1])\n\t\t\n    res=[]\n    for i in range(len(queries)):\n        res.append(solve(s,queries[i]))\n    return res\n            \n```
['Binary Search', 'Sorting', 'Binary Tree', 'Prefix Sum', 'Python']