Tap here to switch tabs
Problem
Submissions

Problem: Maximum Sum Queries

Try to solve the Maximum Sum Queries problem.

Statement

You are given two 00 indexed integer arrays nums1 and nums2, each of length n, and a 2D2 D integer array queries where queries[i] =[xi,yi]= [x_i, y_i].

For the ithi^{th} query, find the maximum value of nums1[j] ++ nums2[j] among all indices j (0≤0 \leq j << n) such that nums1[j] ≥xi\geq x_i and nums2[j] ≥yi\geq y_i. If no such index j exists, the answer for that query is −1-1.

Return an array answer where answer[i] is the answer to the ithi^{ th} query.

Constraints:

  • nums1.length ==== nums2.length

  • n ==== nums1.length

  • 1≤1 \leq n ≤105\leq 10^5

  • 1≤1 \leq nums1[i], nums2[i] ≤109\leq 10^9

  • 1≤1 \leq queries.length ≤105\leq 10^5

  • queries[i].length ==2== 2

  • x_i ==== queries[i][1]

  • y_i ==== queries[i][2]

  • 1≤1 \leq x_i, y_i ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Sum Queries

Try to solve the Maximum Sum Queries problem.

Statement

You are given two 00 indexed integer arrays nums1 and nums2, each of length n, and a 2D2 D integer array queries where queries[i] =[xi,yi]= [x_i, y_i].

For the ithi^{th} query, find the maximum value of nums1[j] ++ nums2[j] among all indices j (0≤0 \leq j << n) such that nums1[j] ≥xi\geq x_i and nums2[j] ≥yi\geq y_i. If no such index j exists, the answer for that query is −1-1.

Return an array answer where answer[i] is the answer to the ithi^{ th} query.

Constraints:

  • nums1.length ==== nums2.length

  • n ==== nums1.length

  • 1≤1 \leq n ≤105\leq 10^5

  • 1≤1 \leq nums1[i], nums2[i] ≤109\leq 10^9

  • 1≤1 \leq queries.length ≤105\leq 10^5

  • queries[i].length ==2== 2

  • x_i ==== queries[i][1]

  • y_i ==== queries[i][2]

  • 1≤1 \leq x_i, y_i ≤109\leq 10^9