<awangdev>219. Contains Duplicate II_2.java
public boolean containsNearbyDuplicate(int[] nums, int k) {
        if (nums == null || nums.length == 0 || k <= 0) {
            return false;
        }
        Map<Integer, List<Integer>> map = new HashMap<>();
        for (int i = 0; i < nums.length; i++) {
            if (map.containsKey(nums[i])) {
                for (int index : map.get(nums[i])) { 
                    if (Math.abs(index - i) <= k) {
                        return true;
                    }
                }
            } else {
                map.put(nums[i], new ArrayList<>());
            }
            map.get(nums[i]).add(i);
        }
        return false;
    }
public boolean var_0 ( int [ ] var_1 , int var_2 ) {
  if ( var_1 == null || var_1 . length == 0 || var_2 <= 0 ) {
    return false ;
  }
  Map < Integer , List < Integer >> var_10 = new HashMap < > ( ) ;
  for ( int var_11 = 0 ;
  var_11 < var_1 . length ;
  var_11 ++ ) {
    if ( var_10 . containsKey ( var_1 [ var_11 ] ) ) {
      for ( int var_14 : var_10 . get ( var_1 [ var_11 ] ) ) {
        if ( Math . abs ( var_14 - var_11 ) <= var_2 ) {
          return true ;
        }
      }
    }
    else {
      var_10 . put ( var_1 [ var_11 ] , new ArrayList < > ( ) ) ;
    }
    var_10 . get ( var_1 [ var_11 ] ) . add ( var_11 ) ;
  }
  return false ;
}
