<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 {
public:
    bool containsDuplicate(vector<int>& nums) {

        int size = nums.size();
        pair<int,int>* pairs_array = new pair<int,int>[size];

        for(auto& key : nums){
            int index = key % size ;

            if(index < 0)
                index +=size ;

            if(pairs_array[index] . second == 0){
                pairs_array[index].first = key;
                pairs_array[index].second++;
            }
            else if(pairs_array[index] . second > 0 && pairs_array[index].first == key)
                pairs_array[index].second++;
            else{
                int i = index +1;
                while (i<size)
                {
                    if(pairs_array[i].second == 0)
                    {
                        pairs_array[i].first = key;
                        pairs_array[i].second++;
                        break;
                    }

                    else if (pairs_array[i].second >0 && pairs_array[i].first == key)
                        {
                            pairs_array[i].second++;
                            break;
                        }
                    else{
                        i++;
                        if(i == size)
                            i=0 ;
                    }
                }
                
            }
        }

        for(int i=0 ; i<size ; i++)
            if(pairs_array[i].second > 1)
                return true;

        return false ;
        
    }
};
63828