Practice Best Sightseeing Pair
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
You are given an integer array values where values[i] represents the value of the ith sightseeing spot. Two sightseeing spots i and j have a distance j - i between them. The score of a pair (i < j) of sightseeing spots is values[i] + values[j] + i - j: the sum of the values of the sightseeing spots, minus the distance between them. Return the maximum score of a pair of sightseeing spots.
Source: Best Sightseeing Pair on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
values = [8,1,5,2,6]
11
# Example 2
values = [1,2]
2
Constraints
Related LeetCode Problems
Practice more problems similar to Best Sightseeing Pair.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.