← ALL NOTES
Array

1014. Best Sightseeing Pair

Score of a sightseeing pair (i < j) is values[i] + values[j] + i - j; maximise it over all pairs. The O(n²) all-pairs scan is avoidable because the score separates into a left part and a right part:…

Loading…