C# 1 line code with LINQ, but only defeat 14% :(


  • 0
    public class Solution {
        public bool ContainsDuplicate(int[] nums) {
            return nums.Count()>nums.Distinct().Count();
        }
    }

  • 0
    J

    Efficiency doesn't depend on lines of code. This program does much more than the problem need in function Distinct().


Log in to reply
 

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