1014. Best Sightseeing Pair

한 쌍의 관광 명소의 최대 점수를 반환

1014. Best Sightseeing Pair

class Solution {
    
    // T: O(n)
    public int maxScoreSightseeingPair(int[] values) {
        int res = 0, cur = 0;
        
        for (int a: values) {
            res = Math.max(res, cur + a);
            cur = Math.max(cur, a) - 1;
        }
        
        return res;
    }
}





© 2017. by yeopoong.github.io

Powered by yeopoong