AlgoMaster Logo

Best Sightseeing Pair

values=[8, 1, 5, 2, 6]
0 / 14
0123481526
algomaster.io
Step:Score = values[i] + values[j] + i - j. Split it: (values[i] + i) + (values[j] - j), and carry the best left part forward.