Skip to content

Instantly share code, notes, and snippets.

@TarasMazepa
Created November 3, 2022 18:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TarasMazepa/ce75683bf3eebcdf58f21a6e7a9aec38 to your computer and use it in GitHub Desktop.
Save TarasMazepa/ce75683bf3eebcdf58f21a6e7a9aec38 to your computer and use it in GitHub Desktop.
int pairedVal = values.front();
int maxScore = 0;
for (int i = 1; i < values.size(); ++i) {
maxScore = max(values[i] + --pairedVal, maxScore);
pairedVal = max(values[i], pairedVal);
}
return maxScore;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment