首页 > 其他 > 详细

leetcode705

时间:2018-10-01 13:12:03      阅读:152      评论:0      收藏:0      [点我收藏+]
class MyHashSet {
public:
    /** Initialize your data structure here. */
    MyHashSet() {
        
    }
    
    void add(int key) {
        if(set[key] == 0)
            set[key]++;
    }
    
    void remove(int key) {
        if(set[key] > 0)
            set[key]--;
    }
    
    /** Returns true if this set contains the specified element */
    bool contains(int key) {
        if(set[key] > 0)
            return true;
        return false;
    }
private:
    int set[1000010] = {0};
};

 

leetcode705

原文:https://www.cnblogs.com/asenyang/p/9734497.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!