I bet that by mistake if any one visited this channel who understand hindi.. trust me he will always watch this guy solution first. Bahut badhiya , lajwab ! Samjhane ka tarika bahut jabardast h bhai .
Ppl who do cp regularly might have been able to do it easily, since it is just basic MEX. Infact there r some great variations of MEX on cf which u guys might wanna try.
I have handled the out of range numbers slightly differently. Instead of checking whether it contains 1 or not and then again iterating to mark out of range numbers to 1, I made 0s and negatives to n + 1 so that I can throw them out of boundary while indexing. int firstMissingPositive(vector& nums) { int n = nums.size(); for (int &num : nums) { if (num= 0) return i + 1; } return n + 1; }
Sincere Thanks to you Mik, that i was able to code this up on my own. You explained this pattern so well that i was able to think of it right after observing the examples.
Bhaiya your content is really amazing. Please make a video on Z algorithm , I have told you to make video a month ago. Waiting for your video from the past 1 month.
This algorithm is truly crackhead! I just don't know, how someone can come up with this solution in a live coding interview without seeing this before.
I did solve yesterday's POTD, however I couldn't figure out that the same strategy could be applied to this problem. Maybe the dots haven't been connected yet in my brain.
bhaiya really excellent explaination. But in this approach we have modified the original array and there is no way to get back to original array(which is not a good practice from interviwers perspective). Is there any way to restore the original array?
Actually with this approach we can’t get back to original array (without some extra space) So the interviewer will tell that you are allowed to modify the input.
Notice how we are running the first for loop. It first checks if nums[i] is 1 or not. So as per the condition, in your example, we will never find 1 and contains1 will be False because there was no 1 in the original input
bhaiya,iske ek brute force mein binary search bhi apply kar sakte hain kya range[1,n] par par every element between 1 to n mein O(n)TC lag jayegi present hai ki nhi array mein vo dekhne ke liye...
In a coding interview, asking for hints can demonstrate your problem-solving skills and ability to collaborate effectively. Here's a polite and effective way to ask for hints: "Would it be possible to get a hint or some guidance on how to approach this problem? I'm currently stuck on how to proceed with O(1) space solution, and would appreciate any insight you can provide." This approach shows that you're willing to seek help when needed, but you're also actively engaged in trying to solve the problem on your own. It's important to strike a balance between independence and seeking assistance during a coding interview.
you are doing a very great job... i just love your content... keep going always.. i'm always with you... keep growing..
Thank you so much 😀
I bet that by mistake if any one visited this channel who understand hindi.. trust me he will always watch this guy solution first. Bahut badhiya , lajwab ! Samjhane ka tarika bahut jabardast h bhai .
Ppl who do cp regularly might have been able to do it easily, since it is just basic MEX. Infact there r some great variations of MEX on cf which u guys might wanna try.
what is mex
Minimum excluded value sir
Yes sir ...har agla contest mein CF ya cc k ek mex t apne darshan de hi deta hai
thanks a lot sir because of you i am getting confidence in DSA.
I have handled the out of range numbers slightly differently. Instead of checking whether it contains 1 or not and then again iterating to mark out of range numbers to 1, I made 0s and negatives to n + 1 so that I can throw them out of boundary while indexing.
int firstMissingPositive(vector& nums) {
int n = nums.size();
for (int &num : nums) {
if (num= 0) return i + 1;
}
return n + 1;
}
Perfect
kth missing positive number wala approach se solve kiya, but tumhara solution dekhe aya hu ab kuch naya sikhunga for sure i know
Sincere Thanks to you Mik, that i was able to code this up on my own. You explained this pattern so well that i was able to think of it right after observing the examples.
i was able to code on the basis of the story you told us. really good explanation
amazing level of teaching Thank you!!!
U made it a cakewalk ❤
Thanks :)
POTD DONE [26.3.24] ✅✅
Hard Qn ki beizzati kardi bhai. Easy bana dala
ikr he is so good
bhaiya kitne badiya smjhate ho yr i mean words are not enough to express how wonderful your videos are keep doing 💕💕
Extremely well explained, thanks :)
you have became my favorite youtuber
Amazing ... as always... your explaination ... motivates me... when im stuck ! thank you !
God of explanation
You are great bro👍👍
goated explanation man thanks
Loved it bhaiya. Thank you !!
Maja aa gaya sir. Gajab approach ha
Very well explained . Thanks for what you do
Best explanation bhaiya thank you so much ❤
You made it so easy 👌🏻
Best Explanation ever thankyou so much
Different level explanation🔥🔥
Love your solution sir!
Legit explanation
Was able to code it when you told the pattern. thanks a lot
well explained!! mja aa gya
Thanks a lot bhaiya ❤❤
Another Approach : we can also replace all numbers which are less than or equals to 0 ( 0) {
return i + 1;
}
}
return (N + 1);
}
}
Absolutely 🙌
All newcomers just stick with this channel for 2 to 3 months. U will surely see a change in you 😎.
well explained bro🙏🙏.
great explanation man.
I think a simpler solution can be implemented if just shift all the elements
Osm Explanation !
Amazing Explanation ❤
Thank You :)
❤❤❤
the great great great person.
Bhaiya your content is really amazing. Please make a video on Z algorithm , I have told you to make video a month ago. Waiting for your video from the past 1 month.
Actually really occupied in my new office. Will soon work on this ❤️
Bhaiya ❤️ GFG POTD v solve kra do daily 🙏🙏❤aapke wjh se DSA me ekdm se interest aa gya h bhaiya ❤️
Actually i gets difficult because of office. Will try my best ❤️❤️❤️
It's clear now why people call you legend everywhere
Awesome!!
This algorithm is truly crackhead!
I just don't know, how someone can come up with this solution in a live coding interview without seeing this before.
I agree.
That’s why i always try to solve similar problems based on a pattern/algorithm.
Yesterday’s POTD was same as this but an east version
I did solve yesterday's POTD, however I couldn't figure out that the same strategy could be applied to this problem.
Maybe the dots haven't been connected yet in my brain.
I just started following my bro yesterday and based on the yesterday's problem i solved todays problem. Really gem👨🏫
did on my own
code:-
class Solution {
public:
int firstMissingPositive(vector& nums) {
int n = nums.size();
int skip = (int)1e5 + 3;
for(int i = 0;i
Nice video brother. Very easy to understand.
Can it be solved with linear time and constant space complexity without modifying the array ?
Bhaiya kya approach hai🫡🫡
Please make a video on leetcode 2935(maximum strongest pair xor II)
Noted 👍🏻❤️
Thanks ❤❤❤❤❤❤
Request : Bring BIT Manipulation playlist soooooooon. Want to learn only from you waiting from past 1 yr.
Sure thing. Just a little occupied at my new office. Will soon start working on that ❤️
@@codestorywithMIK Have you shifted from the current company??
Should we consider space complexity O(1) as we're indeed using the given O(n) space for solving the problem?
The input space is not considered in calculating Space complexity
Hi Sir, can you please make a video on the problem..
Set matrix zeros.
Leetcode No 73.
Thank You in advance.
bhaiya really excellent explaination. But in this approach we have modified the original array and there is no way to get back to original array(which is not a good practice from interviwers perspective). Is there any way to restore the original array?
Actually with this approach we can’t get back to original array (without some extra space)
So the interviewer will tell that you are allowed to modify the input.
Agar 1 nai hai aur 0 aur -ve number hai, to contains0 true ho jayega jabki 1 to hai hi nai. To galat ho jaeyga. Starting me 2 loop chalani padegi.
Notice how we are running the first for loop. It first checks if nums[i] is 1 or not.
So as per the condition, in your example, we will never find 1 and contains1 will be False because there was no 1 in the original input
@@codestorywithMIK ya correct
Sir please make video on dinic’s algorithm and meet in the middle algorithm.
Noted 👍🏻
Sir please make a video on Rabin Karp Algorithm..🙃
Let me plan soon this weekend
yes bhaiya waiting since too long@@codestorywithMIK
Thank you for the response@@codestorywithMIK , I'll be eagerly waiting :)
bhaiya also make videos on GFG PODT problems daily
Currently occupied with office. Will soon plan
bhaiya,iske ek brute force mein binary search bhi apply kar sakte hain kya range[1,n] par par every element between 1 to n mein O(n)TC lag jayegi present hai ki nhi array mein vo dekhne ke liye...
Yes but time completely will be more than O(n)
Bhaiya how to ask for hints in interview can you give us example
In a coding interview, asking for hints can demonstrate your problem-solving skills and ability to collaborate effectively. Here's a polite and effective way to ask for hints:
"Would it be possible to get a hint or some guidance on how to approach this problem? I'm currently stuck on how to proceed with O(1) space solution, and would appreciate any insight you can provide."
This approach shows that you're willing to seek help when needed, but you're also actively engaged in trying to solve the problem on your own. It's important to strike a balance between independence and seeking assistance during a coding interview.
@@codestorywithMIK thankyou sir
sir notes link please
iPad PDF Notes - github.com/MAZHARMIK/Interview_DS_Algo/blob/master/iPad%20PDF%20Notes/Leetcode-41-First%20Missing%20Positive.pdf
bhai qusion tosa hard to ha or
Bhaiya apse baat karni hai number milega kya apka