src/test/java/com/leetcode/hashtable/medium/InsertDeleteGetRandomO1_380.java
public boolean remove(int val) {
      if (!map.containsKey(val)) {
        return false;
      }

      int listPosition = map.get(val);
      Collections.swap(list, list.size() - 1, listPosition);
      int key = list.get(listPosition);
      map.put(key, listPosition);
      map.remove(val);
      list.remove(list.size() - 1);

      return true;
    }
/** Removes a value from the set. Returns true if the set contained the specified element. */
Removes a value from the set. Returns true if the set contained the specified element.
Removes a value from the set . Returns true if the set contained the specified element .
public boolean remove(int val) {
      if (!map.containsKey(val)) {
        return false;
      }
      int listPosition = map.get(val);
      Collections.swap(list, list.size() - 1, listPosition);
      int key = list.get(listPosition);
      map.put(key, listPosition);
      map.remove(val);
      list.remove(list.size() - 1);
      return true;
    }
public boolean remove ( int val ) { if ( ! map . containsKey ( val ) ) { return false ; } int listPosition = map . get ( val ) ; Collections . swap ( list , list . size ( ) - 1 , listPosition ) ; int key = list . get ( listPosition ) ; map . put ( key , listPosition ) ; map . remove ( val ) ; list . remove ( list . size ( ) - 1 ) ; return true ; }
Removes a value from the set.
Removes a value from the set .