Find duplicates in an array - Geeks for Geeks - All the duplicates present in an array - leetcode

preview_player
Показать описание
Find duplicates in an array - Geeks for Geeks - All the duplicates present in an array - leetcode

Problem link :

Course link:

Hi, thanks for watching our video about Bit manipulation in C++
In this video we’ll walk you through:
- Array traversal
- using vectors
- efficient approach
- Solution

TIMESTAMPS
0:00 Intro
00:40 Explanation begins
07:16 IDE solution

ABOUT OUR CHANNEL
Our channel is all about Programming. We cover lots of cool stuff such as solution to problems, concept explanation and tricks to master CP
Check out our channel here:

Don’t forget to subscribe!

CHECK OUT OUR OTHER Playlists

GeeksforGeeks playlist:

Complete C++ Course playlist:

CodeChef Playlist:

LeetCode problems

HackerRank playlist:

FIND US AT

GET IN TOUCH

Given an array a[] of size N which contains elements from 0 to N-1, you need to find all the elements occurring more than once in the given array.

Example 1:

Input:
N = 4
a[] = {0,3,1,2}
Output: -1
Explanation: N=4 and all elements from 0
to (N-1 = 3) are present in the given
array. Therefore output is -1.
Example 2:

Input:
N = 5
a[] = {2,3,1,2,3}
Output: 2 3
Explanation: 2 and 3 occur more than once
in the given array.
Your Task:
Complete the function duplicates() which takes array a[] and n as input as parameters and returns a list of elements that occur more than once in the given array in sorted manner. If no such element is found return -1.

Expected Time Complexity: O(n).
Expected Auxiliary Space: O(n).
Note : The extra space is only for the array to be returned.
Try and perform all operation with in the provided array.

Constraints:
1 less= N less= 105
0 less= A[i] less= N-1, for each valid i

Company Tags
Amazon D-E-Shaw Flipkart Paytm Qualcomm Zoho
Topic Tags
Arrays
Related Courses
Amazon SDE Test Series C++ Foundation
Related Interview Experiences
One97 interview experience set 3 backendnode js developer
Рекомендации по теме
Комментарии
Автор

You can still do it in one loop and without using additional array.

onthego
Автор

is methond ko mere donst ne suggest kiya tha but us time samajh nahi aaya ki wo kya kahana chhah raha tha..
but thank you!

TheBaljitSingh
Автор

Bro we should also not use the frequency array. That's the whole point na.

adityan
Автор

Sir yha pr app postion jb 2 pr phuche to apne phle no count nhi Kiya kyu

thefitfun
Автор

kya koi iska solution without using vector de sakta hai...

leoved
join shbcf.ru