<awangdev>169. Majority Element_1.java
public int majorityElement(int[] nums) {
        if (nums == null || nums.length == 0) {
            return -1;
        }
        Map<Integer, Integer> map = new HashMap<>();
        for (int num : nums) {
            if (!map.containsKey(num)) {
                map.put(num, 0);
            }
            map.put(num, map.get(num) + 1);
        }
        
        int halfLen = nums.length / 2;
        for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
            if (entry.getValue() > halfLen) {
                return entry.getKey();
            }
        }
        return -1;
    }
public int sample_funcname ( int [ ] var_0 ) {
  if ( var_0 == null || var_0 . length == 0 ) {
    return - 1 ;
  }
  Map < Integer , Integer > var_8 = new HashMap < > ( ) ;
  for ( int var_9 : var_0 ) {
    if ( ! var_8 . containsKey ( var_9 ) ) {
      var_8 . put ( var_9 , 0 ) ;
    }
    var_8 . put ( var_9 , var_8 . get ( var_9 ) + 1 ) ;
  }
  int var_14 = var_0 . length / 2 ;
  for ( Map . Entry < Integer , Integer > var_16 : var_8 . entrySet ( ) ) {
    if ( var_16 . getValue ( ) > var_14 ) {
      return var_16 . getKey ( ) ;
    }
  }
  return - 1 ;
}
