topic description
given an array of integers, determine whether there are duplicate elements. If any value appears in the array at least twice, the function returns true. Returns false if each element in the array is different.
sources of topics and their own ideas
my own idea: loop twice, put the same elements in the new array, and determine whether there is a repetition by judging whether the new array is empty or not.
related codes
/ / Please paste the code text below (do not replace the code with pictures)
arr = []
for i in range(len(nums)-1):
for j in range(len(nums)-1): -sharp i!=j
if (i!=j) and (nums[i] == nums[j]):
arr.append(nums[i])
if len (arr):
return True
else:
return False
what result do you expect? What is the error message actually seen?
The problem withis that no matter what nums array you enter, the result is false. Xiaobai also asked the great god to answer the reason.