Approach hintTry it first, then revealHide
Keep the values in an array and each value's index in a hash map. To remove, move the last element into the vacated slot and pop the back, so random picks stay uniform.
Keep the values in an array and each value's index in a hash map. To remove, move the last element into the vacated slot and pop the back, so random picks stay uniform.