public class Solution {
public int majorityElement(int[] num) {
System.out.println(num.length);
int major = num[0];
int count = 1;
for(int i = 1;i < num.length ; i++){
if(num[i] == major){
count++;
}else{
count--;
if(count == 0){
if(i+1 < num.length){
major = num[i+1];
count=1;
i++;
}
}
}
}
return major;
}
}