Value that occurs consecutively most no of times in array : The following code is in java lang:<br>

    int[] array = {1,2,2,3,3,3,2,2,1};
    int k = 2;

What i need to do is find the value (in this case 3), that occurs consecutively more than k times. There can be only one value that occurs>k and if no such value exists, print -1.

Explanation: <br>1 occurs only 1 time consecutively. <br>2 occurs 2 times but its not>k.<br> 3 occurs 3 times, which is>k. Since, there can be only one possible answer, you can stop searching for answer in further values and print 3.<br>
The time limit for code is 0.25s