50 cases Time limit 1000 ms total Memory 256 MB
A word is a peak word if its letters climb strictly up the alphabet to a single peak, then fall strictly back down. It has to climb at least once and fall at least once, and no two neighbouring letters can be the same.
Return whether the word is a peak word. You can return any truthy or falsy value.
Constraints:
len(s) ≤ 12s contains only lowercase lettersExamples:
f("abcba") and f("acb") are truthy
f("abc") is falsy (it never falls)
f("aab") is falsy (two neighbours are the same)
f("abcbc") is falsy (it climbs again after falling)
["abcba"]
True
["acb"]
True
["abc"]
False
["aab"]
False
["abcbc"]
False