Practice Maximum Sum Queries
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Maximum Sum Queries
Problem Statement
You are given two 0-indexed integer arrays nums1 and nums2, each of length n, and a 1-indexed 2D array queries where queries[i] = [xi, yi]. For the ith query, find the maximum value of nums1[j] + nums2[j] among all indices j (0 <= j < n), where nums1[j] >= xi and nums2[j] >= yi, or -1 if there is no j satisfying the constraints. Return an array answer where answer[i] is the answer to the ith query.
Source: Maximum Sum Queries on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
nums1 = [4,3,1,2], nums2 = [2,4,9,5], queries = [[4,1],[1,3],[2,5]]
[6,10,7]
# Example 2
nums1 = [3,2,5], nums2 = [2,3,4], queries = [[4,4],[3,2],[1,1]]
[9,9,9]
# Example 3
nums1 = [2,1], nums2 = [2,3], queries = [[3,3]]
[-1]
Constraints
Related LeetCode Problems
Practice more problems similar to Maximum Sum Queries.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.