Random Remove ADT


  • 0
    S

    Implement APIs for storing numbers:

    class RandomRemoveADT {
    void add(int number);
    bool remove(int number);
    void random_remove();
    vector<int> list_all();
    }

    Note that the data store should remove duplicate numbers

    • For example:
    • add(5), list_all() -> 5
    • add(5), list_all() -> 5
    • add(4), list_all() -> 5,4
    • remove(5), list_all() -> 4
    • random_remove(), list_all() -> empty

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.