[Java/C++/Python] Binary Search
Explanation\n1. Sort input A, since we care the sum and doesn\'t care the order.\n2. Calukate the prefix sum of A, since we want to know the accumulate sum.\n3.
# **Explanation**\n1. Sort input `A`, since we care the `sum` and doesn\'t care the order.\n2. Calukate the prefix sum of `A`, since we want to know the accumulate sum.\n3. Binary seach each query `q` in `query`, and the index is the result.\n4. return result `res`.\n<br>\n\n# **Complexity**\nTime `O(mlogn + n)`\nSpace `O(n)`\n`n = A.size(), m = queries.size()`\n<br>\n\n\n**Java**\n```java\n    public int[] answerQueries(int[] A, int[] queries) {\n        Arrays.sort(A);\n        int n = A.length, m = queries.length, res[] = new int[m];\n        for (int i = 1; i < n; ++i)\n            A[i] += A[i - 1];\n        for (int i = 0; i < m; ++i) {\n            int j = Arrays.binarySearch(A, queries[i]);\n            res[i] = Math.abs(j + 1);\n        }\n        return res;\n    }\n```\n**C++**\n```cpp\n    vector<int> answerQueries(vector<int> A, vector<int>& queries) {\n        sort(A.begin(), A.end());\n        vector<int> res;\n        for (int i = 1; i < A.size(); ++i)\n            A[i] += A[i - 1];\n        for (int& q: queries)\n            res.push_back(upper_bound(A.begin(), A.end(), q) - A.begin());\n        return res;\n    }\n```\n\n**Python**\n```py\n    def answerQueries(self, A: List[int], queries: List[int]) -> List[int]:\n        A = list(accumulate(sorted(A)))\n        return [bisect_right(A, q) for q in queries]\n```\n
['C', 'Python', 'Java']