Tap here to switch tabs
Problem
Submissions

Problem: Best Sightseeing Pair

med
30 min
Try to solve the Best Sightseeing Pair problem.

Statement

You are given an integer array values, where values[i] represents the score of the sightseeing spot at index i. Choose two different indices i and j such that i<ji < j, and define the score of this pair as values[i] + values[j] + i - j.

Return the maximum possible score over all valid pairs.

Constraints:

  • 2≤2 \leq values.length ≤5⋅104\leq 5 \cdot 10^4

  • 1≤1 \leq values[i] ≤1000\leq 1000

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Best Sightseeing Pair

med
30 min
Try to solve the Best Sightseeing Pair problem.

Statement

You are given an integer array values, where values[i] represents the score of the sightseeing spot at index i. Choose two different indices i and j such that i<ji < j, and define the score of this pair as values[i] + values[j] + i - j.

Return the maximum possible score over all valid pairs.

Constraints:

  • 2≤2 \leq values.length ≤5⋅104\leq 5 \cdot 10^4

  • 1≤1 \leq values[i] ≤1000\leq 1000