C# Array Maximal Adjacement Difference
static long ArrayMaximalAdjacentDifference(int[] a)
{
long dif = 0;
for (int i = 1; i < a.Length - 1; i++)
{
dif = Math.Max(dif, Math.Max(Math.Abs((long)a[i] - a[i - 1]), Math.Abs((long)a[i] - a[i + 1])));
}
return dif;
}
This checks the gap between each pair of neighbors and returns the largest difference.