Tap here to switch tabs
Problem
Submissions

Problem: Maximize Y-Sum With a Triplet of Distinct X-Values

med
30 min
Try to solve the Maximize Y‑Sum by Picking a Triplet of Distinct X‑Values problem.

Statement

Given two integer arrays x and y of the same length n, find three distinct indices i, j, and k such that the values x[i], x[j], and x[k] are all pairwise distinct.

Return the maximum possible value of y[i] + y[j] + y[k]. If it is impossible to choose three indices satisfying this condition, return −1-1.

Constraints:

  • n == x.length == y.length

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

  • 1≤1 \leq x[i], y[i] ≤106\leq 10^6

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximize Y-Sum With a Triplet of Distinct X-Values

med
30 min
Try to solve the Maximize Y‑Sum by Picking a Triplet of Distinct X‑Values problem.

Statement

Given two integer arrays x and y of the same length n, find three distinct indices i, j, and k such that the values x[i], x[j], and x[k] are all pairwise distinct.

Return the maximum possible value of y[i] + y[j] + y[k]. If it is impossible to choose three indices satisfying this condition, return −1-1.

Constraints:

  • n == x.length == y.length

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

  • 1≤1 \leq x[i], y[i] ≤106\leq 10^6