217. Contains Duplicate #Easy

来源:互联网 发布:淘宝上卖面膜 许可证 编辑:程序博客网 时间:2024/05/29 12:19

https://leetcode.com/problems/contains-duplicate/

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.

一种解法:先对数组进行快速排序,遍历排序后的数组,查看是否连续出现相同元素 

要使用C语言库函数qsort需要自己实现一个比较大小的函数




2 0
原创粉丝点击