Yahoo India Web Search

Search results

  1. A medium-level problem that asks to find all the integers that appear twice in an array of length n in O(n) time and constant space. See the input, output, and constraints for examples and solutions.

    • Discuss (999+)

      Find All Duplicates in an Array - Level up your coding...

  2. Dec 14, 2023 · Learn how to print the duplicates in an array using nested loop, hash-map, or sorting algorithms. See examples, code, and time complexity analysis for C++, Java, Python, and Javascript.

    • 12 min
  3. Learn how to find all the elements occurring more than once in an array of size n with elements from 0 to n-1. See examples, constraints, time and space complexity, and company tags for this easy problem.

  4. class Solution { public: vector<int> findDuplicates(vector<int>& nums) { vector<int> ans; for (const int num : nums) { nums[abs(num) - 1] *= -1; if (nums[abs(num) - 1] > 0) ans.push_back(abs(num)); } return ans; } }; LeetCode Solutions in C++20, Java, Python, MySQL, and TypeScript.

  5. Jul 16, 2024 · Given an array of n elements containing elements from 0 to n-1, with any of these numbers appearing any number of times, find these repeating numbers in O(n) and using only constant memory space. Example: Input: n = 7 , array = {1, 2, 3, 1, 3, 6, 6} Output: 1, 3 and 6. Explanation: Duplicate element in the array are 1 , 3 and 6

    • 12 min
  6. Learn how to find all the numbers that appear twice in an array using cyclic sort and constant extra space. See the problem description, solution approach, code snippet, and time and space complexity analysis.

  7. People also ask

  8. Feb 14, 2017 · Learn how to solve this problem using Java, C++, Python or Go. Given an array of integers in the range [1, n] where each element appears once or twice, return an array of duplicates.

  1. Searches related to find all duplicates in an array

    set mismatch leetcode