Warning: session_start(): open(/var/lib/php/sessions/sess_8suu8ph0g2nkvhkklgo1ufkj31, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
sclass MountainsAndValleys {
double[] values;
new IntBuffer highs;
new IntBuffer lows;
run {
int n = l(values);
if (n == 0) ret;
highs.add(values[0]);
lows.add(values[0]);
int i = 1;
while (i < n) {
// find plateau
var value = values[i];
int j = i+1;
while (j < n && values[j] == value) ++j;
// are we going up or down?
var last = values[i-1];
if (value > last)
highs.set(l(highs)-1, i); // replace last high
else
lows.set(l(lows)-1, i); // replace last low
}
}
}