Find all duplicate and missing numbers from 1 to N

preview_player
Показать описание


Given an unsorted array of size n. Array elements are in the range from 1 to n. Some numbers from set {1, 2, …n} are missing and some are repeating in the array. Find these two numbers in order of one space.

Input:[3 1 1 5 3]

Duplicate = 3,1 Missing = 2,4 .
------------------------------------------------------------------------------------------
Here are some of the gears that I use almost everyday:

PS: While having good gears help you perform efficiently, don’t get under the impression that they will make you successful without any hard work.
Рекомендации по теме
Комментарии
Автор

superb content!!
DP playlist is amazing. "jaise mai samjhata hu waise koi ni samjhayega" :D

PriyankaGupta-bjvc
Автор

When you are watching other youtube channel video then First I watching 🧿 then think about whether like video or not but when you see Aditya Verma bhai youtube like content then first I like 👍 then watching 🧿

princegarg
Автор

Thank you so much for all the efforts in making these. I bagged an internship at Samsung in my 3rd year itself competing with 4th years and at least 90% of credits goes to you. Keep helping.
Please do make more videos on trees and a playlist on graph and backtracking.

ps: outro and intro song bata de bhai tune bohot sahi he.

swasthiknayak
Автор

I watch all your videos the second they are uploaded... Keep going bro
Great work!!

kumarshubham
Автор

// my solution to the interviewbit problem

vector<int> vector<int> &a)
{
int n = a.size();
vector<int> test(a.size() + 1);
for(int i = 0 ; i < n ; i++) test[i+1] = a[i];

int x, y;

for(int i = 1 ; i <= n ; i++)
{
int idx = abs(test[i]);
if(test[idx] < 0) x = idx;
else test[idx] *= -1;
}

for(int i = 1 ; i <= n ; i++)
if(test[i] > 0) y = i;

vector<int> ans = {x, y};
return ans;
}

tanmaytyagi
Автор

for one question, I did the whole playlist, nice flow of understanding ✨✨✨✨

RohitKumar-cvqb
Автор

Bahiya when you will complete rest dp Playlist. I am waiting
Please complete asap
I need it.
I am watching all your videos
All the videos are amazing

kunalkumarbarman
Автор

Can you please explain the dialpad problem of Samsung interview

adityadixit
Автор

Please someone suggest some interesting questions to ask the interviewer in the end

DMDRPBHU
Автор

if the input array will be like this [63, 86, 2, 9, 5, 86] how we can resolve it. Actually how we find the i-1 for that?

amazingproducts
Автор

Please share your code if possible, i need to refer it to remove some doubts

agarwalminal
Автор

in this approach we perform lot of swap operation.. this is lime consuming.

manukhurana
Автор

Can anyone tell me what drawback he told? I don't know Hindi...

snegar
Автор

Bhaiya greedy approach ki bi playlist bna do plss

rishitiwari
Автор

I'm a begginer...from which playlist of yours I should

fuadhasan
Автор

Bhai aapne reply nh kia linkedin pr aapko jese time mile please do reply

neilchaudhary
Автор

Cpp code
int sz = arr.size();
int i = 0;
while(i < sz){
if(arr[i] == i+1 || arr[i] == arr[arr[i]-1]){
i++;
}
else {
int temp = arr[arr[i]-1];
arr[arr[i]-1] = arr[i];
arr[i] = temp;
}
}

for(int j=0;j<arr.size();j++){
if(arr[j] != j+1)
return {arr[j], j+1};
}

ManinderSingh-blxe
Автор

int *findTwoElement(int *arr, int n) {
int i =0;
int r = 0;
int m =0;
int correct_pos;

for(int i=0;i<n;)
{
correct_pos=arr[i]-1;
if(arr[correct_pos]!=arr[i])
{
swap(arr[i], arr[correct_pos]);
}
else
i++;

}



for(int j =0;j<n;j++)
{
if(arr[j]!= 1+j)
{
r = arr[j];
m = 1+j;
}

}
int a[] = {r, m};
int* p = a;

return p;
}

himanshujoshi
Автор

din find you uploading much of videos now ... Covid mei nipatt gaye kya ?? jk

saishankar
Автор

Can you please explain the dialpad problem of Samsung interview

adityadixit