Skip to content

Commit ac12205

Browse files
authored
Create 1014. Best Sightseeing Pair
1 parent 2e09c40 commit ac12205

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

1014. Best Sightseeing Pair

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution {
2+
public:
3+
int maxScoreSightseeingPair(vector<int>& values) {
4+
map<int,int>mp;
5+
int maxi = INT_MIN;
6+
for(int i=0;i<values.size();i++){
7+
if(mp.size()>0){
8+
maxi = max(maxi,max(mp.begin()->first-i+values[i],mp.rbegin()->first-i+values[i]));
9+
}
10+
mp[i+values[i]] = i;
11+
}
12+
return maxi;
13+
}
14+
};

0 commit comments

Comments
 (0)