You are given two 0-indexed integer arrays
nums1
andnums2
, each of lengthn
, and a 1-indexed 2D arrayqueries
wherequeries[i] = [xi, yi]
.For the
ith
query, find the maximum value ofnums1[j] + nums2[j]
among all indicesj
(0 <= j < n)
, wherenums1[j] >= xi
andnums2[j] >= yi
, or -1 if there is noj
satisfying the constraints.Return an array
answer
whereanswer[i]
is the answer to theith
query.
c++
1 |
|