Contains Duplicate
Question
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.
Answer
solution1:this is my answer.
solution2:
Knowledge:
python中列表排序方法,sort方法与sorted方法。
sort排序方法是直接修改原列表list排序方法,其调用形式为:a.sort()
。
sorted()方法 保留原列表得到一个额外的已经排序好的列表,其调用形式为b = sorted(a)。
sorted()方法可以用在任何数据类型的序列中,返回的总是一个列表形式。
Last updated
Was this helpful?