go: add «1014. Best Sightseeing Pair»

URL:	https://leetcode.com/problems/best-sightseeing-pair/
Signed-off-by: Matej Focko <me@mfocko.xyz>
This commit is contained in:
Matej Focko 2024-12-27 11:07:01 +01:00
parent b67d43c82e
commit 945eef30d1
Signed by: mfocko
SSH key fingerprint: SHA256:icm0fIOSJUpy5+1x23sfr+hLtF9UhY8VpMC7H4WFJP8

View file

@ -0,0 +1,15 @@
package main
func maxScoreSightseeingPair(values []int) int {
maxLeft := values[0]
maxScore := 0
for i := 1; i < len(values); i++ {
rightScore := values[i] - i
maxScore = max(maxScore, maxLeft+rightScore)
maxLeft = max(maxLeft, values[i]+i)
}
return maxScore
}