Simple single line C# solution using HashSet


  • 0
    C
    public class Solution 
    {
        public bool ContainsDuplicate(int[] nums) 
        {
            return !Enumerable.SequenceEqual(nums, new HashSet<int>(nums).ToArray());
        }
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.