I do not know how to write an algorithm that outputs the maximal value of
the difference (s[k] - s[k-2]) for arbitrary sequence of integers
s,íK., s[n], where 2<n, 2<k<=n.
thanks your help!
Just go through all the elements of the array and calculate the
differences. When you start s-s is the start value and this is the
biggest so far. Store it in a variable. Then go on and if you find a
bigger store than one in the max variable.
[ back to toc ]