C # program to find longest alternating subarray starting from every index .
using System ; class Longest { public static void longestAlternating ( int [ ] arr , int n ) { int [ ] count = new int [ n ] ;