LeetCode 217. Contains Duplicate C++
发布时间:2020-12-16 09:14:17 所属栏目:百科 来源:网络整理
导读:Given an array of integers,find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array,and it should return false if every element is distinct. Example 1: Input: [1,2,3,1]Out
Given an array of integers,find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array,and it should return false if every element is distinct. Example 1: Input: [1,2,3,1] Output: true Example 2: Input: [1,4] Output: false Example 3: Input: [1,1,4,2] Output: true 解法: 先排序,用sort() 然后判断是否相等 //时间<86% (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |