最长平台
public class Test
{
public static void main(String args[])
{
int a[] = new int[0]; //{1, 2, 2, 3, 3, 3, 4, 4, 5};
System.out.println(longest_plateau(a));
}
public static int longest_plateau(int a[])
{
if (a.length < 1) // IF ARRAY IS NULL(NIL), OUTPUT ZERO.
return 0;
int length = 1;
for (int i = 1; i < a.length; ++i) // i uses to go through array a[];
if ( a[i] == a[i - length])
++length;
return length;
}
}