0

Dear all,

I'm a newbie learning Java. Could you please help me on how to find the length of the longest group of duplicates in an array using Java.

Let's say we have an array of integers as follows

{9 7 7 7 7 3 2 1 1 5 5 5 5 5 4 1 3 3 3 9 7 7 3 5 }

The answer is 4 as the group of 5s has 4 duplicates

while the group of 7s has 3 duplicates, the group of 3s has only 2. The "duplicate" here is defined as an integer which has the same value of the integer in the n-1th position.

I'd greatly appreciate your help on this problem.

VM