Java program to find longest alternating subarray starting from every index .
import java . util . * ; class Longest { public static void longestAlternating ( int arr [ ] , int n ) { int [ ] count = new int [ n ] ;