Untitled

mail@pastecode.io avatar
unknown
java
2 years ago
325 B
2
Indexable
Never
public int maxOcurrenceMaxValue(int[] array){

    int cant=1;
    int max=array[0];
    
    for(int i=1;i<array.length;i++){
        if(max==array[i]){
            cant++;
        } 
        else if (max < array[i]) {
            max = array[i];
            cant = 1;
        }
    }
    
    return cant;
}