Trains the technique from
LeetCode 1014Best Sightseeing PairThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
Interpretive boards stand one step apart along a ridge trail, numbered 0 upward. Board i carries a review score values[i], which may be negative when visitors disliked it.
A guide picks an ordered pair of boards: an earlier board i and a later board j, with i strictly before j. The pair is rated by adding the two review scores together and then taking away the number of steps walked between the two boards, which is j - i.
Return the highest rating any such pair reaches.
Example 1
Pairing board 4 with board 5 adds 4 and 100 and takes away the single step between them, giving 103. No other pair reaches that.
Example 2
Only one pair exists. Adding -3 and -4 gives -7, and one step is walked, so the rating is -8.
Example 3
Boards 0 and 2 add to 1001 and are two steps apart, for 999. Boards 1 and 2 add to 500 and are one step apart, for 499, and boards 0 and 1 rate -500.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def max_score_sightseeing_pair(values: list[int]) -> int:public int maxScoreSightseeingPair(int[] values)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.