Matej Focko
945eef30d1
URL: https://leetcode.com/problems/best-sightseeing-pair/ Signed-off-by: Matej Focko <me@mfocko.xyz>
15 lines
276 B
Go
15 lines
276 B
Go
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
|
|
}
|