Bug Report: Cpp Compiler Error Issue


  • 0
    Y

    Hi Admin,

    When I submit the following cpp code, the compiler complains saying that "Line 14: expected unqualified-id before 'delete'". Could you take a look at this issue? I am sure the code must got a WA instead of Compile Error.

    class RandomizedSet {
    public:
        /** Initialize your data structure here. */
        RandomizedSet() {
            
        }
        
        /** Inserts a value to the set. Returns true if the set did not already contain the specified element. */
        bool insert(int val) {
            return true;
        }
        
        /** Deletes a value from the set. Returns true if the set contained the specified element. */
        bool delete(int val) {
            return false;
        }
        
        /** Get a random element from the set. */
        int getRandom() {
            return 1;
        }
    };
    
    /**
     * Your RandomizedSet object will be instantiated and called as such:
     * RandomizedSet obj = new RandomizedSet();
     * bool param_1 = obj.insert(val);
     * bool param_2 = obj.delete(val);
     * int param_3 = obj.getRandom();
     */
    

    Thanks


  • 0

    @yular This is fixed. Please rename the member function name delete to remove.


  • 0
    Y

    @1337c0d3r thx!


Log in to reply
 

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