<p>Given an integer array <code>nums</code>, return <code>true</code> if any value appears <strong>at least twice</strong> in the array, and return <code>false</code> if every element is distinct.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">nums = [1,2,3,1]</span></p>

<p><strong>Output:</strong> <span class="example-io">true</span></p>

<p><strong>Explanation:</strong></p>

<p>The element 1 occurs at the indices 0 and 3.</p>
</div>

<p><strong class="example">Example 2:</strong></p>

<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">nums = [1,2,3,4]</span></p>

<p><strong>Output:</strong> <span class="example-io">false</span></p>

<p><strong>Explanation:</strong></p>

<p>All elements are distinct.</p>
</div>

<p><strong class="example">Example 3:</strong></p>

<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">nums = [1,1,1,3,3,4,3,2,4,2]</span></p>

<p><strong>Output:</strong> <span class="example-io">true</span></p>
</div>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
	<li><code>-10<sup>9</sup> &lt;= nums[i] &lt;= 10<sup>9</sup></code></li>
</ul>

class Solution {
    struct exc {};
    struct smOl_hash_map {
        struct node {
            ~node() {
                if (next)
                    delete next;
            }
            int v;
            node* next;
        };
        
        vector<node*> data;
        smOl_hash_map(size_t size) : data(size, {}) {
            
        }
        ~smOl_hash_map() {
            for (auto& i : data) {
                if (i)
                    delete i;
            }
        }
        void put(int v) {
            node** n = &data[static_cast<unsigned>(v % data.size())];
            if (!*n) {
                *n = new node{.v = v};
                return;
            }
            node* n_ = *n;
            while(true) {
                if (n_->v == v) {
                    cout << v << "   " << n_->v;
                    throw exc{};
                }
                if (!n_->next) {
                    n_->next = new node{.v = v};
                    return;
                }
                n_ = n_->next;
            }
        }
    };
public:
    bool containsDuplicate(const vector<int>& nums) const {
        smOl_hash_map h(nums.size());
        try {
            for (auto i : nums)
                h.put(i);
        } catch(const exc& n) {
            return true;
        }
        
        return false;
    }
};
69396