6
"Almonds? Oh yeah, I have tried those before. Covered in chocolate." - Dudu, 2015.
Note: This problem is identical to Small and Large Weird Measurements, but with different bounds.
Dudu is trying to achieve a perfect beach body for his upcoming trip to Thailand. As such, as part of his strict regime he weighs himself every morning.
A few intervals of time are good, with a constant decrease of weight, and a few are bad, with a constant increase of weight. But some intervals are just weird.
We say that the measurements from an interval are weird if they alternate between increasing and decreasing. For instance, if the measurements for consecutive days are [1,3,2,5,1], these measurements are weird. If the measurements are [1,3,5,4], then they are not weird, since the value increases between 1 and 3 and between 3 and 5. Note that all intervals of size 1 are weird by this definition.
Given a sequence of integers, we are interested in figuring out how many intervals are weird. See the sample below for a better explanation.
