Created
February 24, 2017 22:50
-
-
Save hikilaka/426b43d0fbeff52141055e29a771897c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool isSmooth(std::vector<int> arr) { | |
auto first = std::begin(arr); | |
auto last = std::rbegin(arr); | |
if (*first == *last) { | |
if ((arr.size() % 2) == 0) { | |
std::advance(first, arr.size() / 2); | |
auto next = std::prev(first); | |
return (*first + *next) == *last; | |
} else { | |
std::advance(first, arr.size() / 2); | |
return *first == *last; | |
} | |
} else { | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment