Python - Prefix Sum + Binary Search Solution
NOTE that we have to find a "Subsequence" not a "Subarray". So we can pick any elements in sequence. Hence, we can sort the given array first, turn it into its 
NOTE that we have to find a "Subsequence" not a "Subarray". So we can pick any elements in sequence. Hence, we can sort the given array first, turn it into its prefix sum array and then apply binary search.\n\n\n```\ndef answerQueries(self, nums: List[int], queries: List[int]) -> List[int]:\n        output = []\n        \n        # First Sort the given array\n        nums.sort()\n        \n        n = len(nums)\n        \n        # Prefix Sum\n        for i in range(1, n): nums[i] += nums[i - 1]\n        \n        # Each Query is a target sum\n        # So, we want to find the largest Subsequence  with sum <= query\n        for query in queries:\n            start = 0\n            end = n - 1\n            \n            result = -1\n            \n            while start <= end:\n                mid = start + (end - start) // 2\n                \n                # If the sum at mid is <= query, this is one possible solution\n                # WE want the longest Subsequence so we will continue searching by making start = mid + 1\n                # E.g. what if after mid we have some 0s. That would result in same sum but size of subsequence will be larger than before\n                if nums[mid] <= query:\n                    result = mid\n                    start = mid + 1\n                else:\n                    end = mid - 1\n            \n\t\t\t# Since 0 based indexing so e.g. result = 0 means size of subsequence is 1\n            output.append(result + 1)\n        \n        return output\n```
['Binary Search', 'Prefix Sum', 'Python']