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

&nbsp;
Example 1:
Input: nums = [1,2,3,1]
Output: true
Example 2:
Input: nums = [1,2,3,4]
Output: false
Example 3:
Input: nums = [1,1,1,3,3,4,3,2,4,2]
Output: true

&nbsp;
Constraints:


	1 &lt;= nums.length &lt;= 105
	-109 &lt;= nums[i] &lt;= 109


class Solution:
    def containsDuplicate(self, nums: List[int]) -> bool:
        return len(nums) != len(set(nums))
class Solution {
    public boolean containsDuplicate(int[] nums) {
        Arrays.sort(nums);
        int n = nums.length;
        for (int i = 1; i < n; i++) {
            if (nums[i] == nums[i - 1])
                return true;
        }
        return false;
    }
}
class Solution {
public:
    bool containsDuplicate(vector<int>& nums) {
        sort(nums.begin(), nums.end());
        int n = nums.size();
        for (int i=0; i<n-1; i++){
            if (nums[i]==nums[i+1])
        return true;
            }
        return false;

    }
};
var containsDuplicate = function(nums) {
    if(nums.length <= 1) return false;
    let cache = {};
    let mid = Math.floor(nums.length /2)
    let left = mid -1;
    let right  = mid;
    while(left >= 0 || right < nums.length) {
        if(nums[left] === nums[right]) {
            return true;
        };
        if(cache[nums[left]]){
            return true
        } else {
            cache[nums[left]] = true; 
        }
        if(cache[nums[right]]){
            return true;
        } else{
            cache[nums[right]] = true;
        }
        left--;
        right++;
    }
    return false;
};
Contains Duplicate