NeetCode #787LC-3572MediumGreedy
← Back to All Problems

#787 · #3572 · Maximize Y‑Sum by Picking a Triplet of Distinct X‑Values(最大化 X 值三元组的 Y 值和)

📌 Problem Statement & Constraints

You are given two integer arrays x and y of the same length n. Choose three indices i, j, k with distinct x values so that y[i] + y[j] + y[k] is maximised. Return that maximum sum, or -1 if it is impossible. Constraints: 3 <= n <= 10^5, 1 <= x[i], y[i] <= 10^9.
🔒

Sign In to Unlock Full Solutions for All 973 Problems

Sign in to access step-by-step logic, benchmark Python3 code, complexity breakdown, and offline export!