maxSoFar to 0, which will store the maximum score found so far.bestSoFar to values[0], which will store the maximum value of values[i] + i encountered up to the current index.j, calculate the potential score as bestSoFar + values[j] - j.
b. Update maxSoFar with the maximum of maxSoFar and the potential score.
c. Update bestSoFar with the maximum of bestSoFar and values[j] + j.maxSoFar as the maximum score of a pair of sightseeing spots.