<p>Given two integer arrays <code>nums1</code> and <code>nums2</code>, return <em>an array of their <span data-keyword="array-intersection">intersection</span></em>. Each element in the result must be <strong>unique</strong> and you may return the result in <strong>any order</strong>.</p>

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

<pre>
<strong>Input:</strong> nums1 = [1,2,2,1], nums2 = [2,2]
<strong>Output:</strong> [2]
</pre>

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

<pre>
<strong>Input:</strong> nums1 = [4,9,5], nums2 = [9,4,9,8,4]
<strong>Output:</strong> [9,4]
<strong>Explanation:</strong> [4,9] is also accepted.
</pre>

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

<ul>
	<li><code>1 &lt;= nums1.length, nums2.length &lt;= 1000</code></li>
	<li><code>0 &lt;= nums1[i], nums2[i] &lt;= 1000</code></li>
</ul>

class Solution {
public:
    vector<int> intersection(vector<int>& nums1, vector<int>& nums2) {
        bool arr1[1001] = {0};
        for (auto n : nums1)
            arr1[n] = true;

        bool arr2[1001] = {0};
        for (auto n : nums2)
            arr2[n] = true;

        std::vector<int> ans;
        for (int i = 0; i < 1001; ++i) {
            if (arr1[i] & arr2[i])
                ans.push_back(i);
        }

        return ans;
    }

    // vector<int> intersection(vector<int>& nums1, vector<int>& nums2) {
    //     std::unordered_set<int> s(nums1.begin(), nums1.end());
        
    //     std::unordered_set<int> res;
        
    //     for (auto v : nums2) {
    //         if (s.count(v) && res.count(v) == 0) {
    //             res.insert(v);
    //         }
    //     }

    //     return std::vector<int>(res.begin(), res.end());
    // }
};
13000