public int majorityNumber(List<Integer> nums) {
        int candidate = nums.get(0);
        int count = 1;
        for(int i = 1; i < nums.size(); i++){
            if(candidate == nums.get(i)){
                count++;
            }else if(count == 0){
                candidate = nums.get(i);
                count = 1;
            }else{
                count--;
            }
        }
        return candidate;
    }