About 190,000 results
Open links in new tab
  1. How to Find Duplicates in a List – Python | GeeksforGeeks

    Nov 27, 2024 · Removing duplicates from a list is a common operation in Python which is useful in scenarios where unique elements are required. Python provides multiple methods to achieve this. Using set() method is most efficient for unordered lists.

  2. Check if array contains duplicates - GeeksforGeeks

    Aug 29, 2024 · Given an integer array arr [], check if the array contains any duplicate value. Examples: Explanation: 4 is the duplicate value. Explanation: All values are distinct. The simple idea is to use a nested loop to compare each element in the array with every other element.

  3. python - How to check if a list contains duplicate items ... - Stack ...

    Jan 11, 2018 · The has_duplicate() Function takes care of determining if a list contains duplicates. def has_duplicates(listObj): return len(listObj) != len(set(listObj)) print(has_duplicates([1, 2, 1, 1, 4, 7])) ## PRINTS: True print(has_duplicates([9, 2, 5, 4, 7])) ## PRINTS: False

  4. 217. Contains Duplicate - In-Depth Explanation - AlgoMonster

    In-depth solution and explanation for LeetCode 217. Contains Duplicate in Python, Java, C++ and more. Intuitions, example walk through, and complexity analysis. Better than official and forum solutions.

  5. Identify duplicate values in a list in Python - Stack Overflow

    You can print duplicate and Unqiue using below logic using list. def dup(x): duplicate = [] unique = [] for i in x: if i in unique: duplicate.append(i) else: unique.append(i) print("Duplicate values: ",duplicate) print("Unique Values: ",unique) list1 = [1, 2, 1, 3, 2, 5] dup(list1)

  6. Contains Duplicate - LeetCode

    Contains Duplicate - Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct. Example 1: Input: nums = [1,2,3,1] Output: true Explanation: The element 1 occurs at the indices 0 and 3.

  7. List contains duplicate Python solution - Stack Overflow

    May 24, 2020 · This can be done simply by converting the list into set, which cannot contain duplicates. Converting the list into set will remove all duplicates so if the set is smaller than the list, the list contains duplicates

  8. LeetCode 217. Contains Duplicate — Python Solution - Medium

    Jan 22, 2024 · Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct. This problem is one of the easier problems to do as long as...

  9. Contains Duplicate in Python - Online Tutorials Library

    Learn how to check for duplicate elements in a list using Python with various methods and examples.

  10. Python Challenge: Check Duplicates in Array

    Write a Python function `contains_duplicates` that determines whether a given list of integers contains any duplicate elements. The function should return `True` if there are duplicates and `False` otherwise. - The input will always be a list of integers. - The list can be empty, in which case the function should return `False`.