<awangdev>Majority Number III_1.java
public int majorityNumber(ArrayList<Integer> nums, int k) {
        if (nums == null || nums.size() == 0) {
            return -1;
        }
        HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
        for (Integer num : nums) {
            if (map.containsKey(num)) {
                map.put(num, map.get(num) + 1);
            } else {
                if (map.size() == k) {
                    Iterator<Map.Entry<Integer, Integer>> iter = map.entrySet().iterator();
                    while (iter.hasNext()) {
                        Map.Entry<Integer, Integer> entry = iter.next();
                        if (entry.getValue() - 1 == 0) {
                            iter.remove();
                        } else {
                            map.put(entry.getKey(), entry.getValue() - 1);
                        }
                    }
                } else {
                    map.put(num, 1);
                }
            }
        }
        
        int result = 0;
        int max = 0;
        for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
            if (entry.getValue() > max) {
                max = entry.getValue();
                result = entry.getKey();
            }
        }
        return result;
    }
public int sample_funcname ( ArrayList < Integer > var_2 , int var_3 ) {
  if ( var_2 == null || var_2 . size ( ) == 0 ) {
    return - 1 ;
  }
  HashMap < Integer , Integer > var_9 = new HashMap < Integer , Integer > ( ) ;
  for ( Integer var_10 : var_2 ) {
    if ( var_9 . containsKey ( var_10 ) ) {
      var_9 . put ( var_10 , var_9 . get ( var_10 ) + 1 ) ;
    }
    else {
      if ( var_9 . size ( ) == var_3 ) {
        Iterator < Map . Entry < Integer , Integer >> var_19 = var_9 . entrySet ( ) . iterator ( ) ;
        while ( var_19 . hasNext ( ) ) {
          Map . Entry < Integer , Integer > var_22 = var_19 . next ( ) ;
          if ( var_22 . getValue ( ) - 1 == 0 ) {
            var_19 . remove ( ) ;
          }
          else {
            var_9 . put ( var_22 . getKey ( ) , var_22 . getValue ( ) - 1 ) ;
          }
        }
      }
      else {
        var_9 . put ( var_10 , 1 ) ;
      }
    }
  }
  int var_26 = 0 ;
  int var_27 = 0 ;
  for ( Map . Entry < Integer , Integer > var_22 : var_9 . entrySet ( ) ) {
    if ( var_22 . getValue ( ) > var_27 ) {
      var_27 = var_22 . getValue ( ) ;
      var_26 = var_22 . getKey ( ) ;
    }
  }
  return var_26 ;
}
