First Missing Positive | In Depth Intuition | Clean Code | Leetcode 41 | codestorywithMIK

Поділитися
Вставка
  • Опубліковано 9 січ 2025

КОМЕНТАРІ •

  • @constant.learner.123
    @constant.learner.123 9 місяців тому +28

    you are doing a very great job... i just love your content... keep going always.. i'm always with you... keep growing..

  • @udayshankar-e6v
    @udayshankar-e6v 9 місяців тому +3

    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 .

  • @xiaoshen194
    @xiaoshen194 9 місяців тому +11

    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.

    • @krishnan828
      @krishnan828 9 місяців тому +1

      what is mex

    • @AryanAryan-ks5ib
      @AryanAryan-ks5ib 9 місяців тому +1

      Minimum excluded value sir

    • @AryanAryan-ks5ib
      @AryanAryan-ks5ib 9 місяців тому

      Yes sir ...har agla contest mein CF ya cc k ek mex t apne darshan de hi deta hai

  • @shubhambalodhi6485
    @shubhambalodhi6485 9 місяців тому +7

    thanks a lot sir because of you i am getting confidence in DSA.

  • @joydeep-halder
    @joydeep-halder 9 місяців тому +2

    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;
    }

  • @iWontFakeIt
    @iWontFakeIt 9 місяців тому +2

    kth missing positive number wala approach se solve kiya, but tumhara solution dekhe aya hu ab kuch naya sikhunga for sure i know

  • @Ashutosh07535
    @Ashutosh07535 9 місяців тому +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.

  • @shloksuman8164
    @shloksuman8164 9 місяців тому +2

    i was able to code on the basis of the story you told us. really good explanation

  • @abhiramvanama5266
    @abhiramvanama5266 9 місяців тому +1

    amazing level of teaching Thank you!!!

  • @oqant0424
    @oqant0424 9 місяців тому +2

    U made it a cakewalk ❤
    Thanks :)
    POTD DONE [26.3.24] ✅✅

  • @souravjoshi2293
    @souravjoshi2293 9 місяців тому +5

    Hard Qn ki beizzati kardi bhai. Easy bana dala

    • @paul9005
      @paul9005 9 місяців тому

      ikr he is so good

  • @sourabhsharma2511
    @sourabhsharma2511 6 місяців тому +1

    bhaiya kitne badiya smjhate ho yr i mean words are not enough to express how wonderful your videos are keep doing 💕💕

  • @nishantraj376
    @nishantraj376 4 місяці тому +1

    Extremely well explained, thanks :)

  • @paul9005
    @paul9005 9 місяців тому

    you have became my favorite youtuber

  • @mewaconite
    @mewaconite 9 місяців тому

    Amazing ... as always... your explaination ... motivates me... when im stuck ! thank you !

  • @k-CE-OmkarPathak
    @k-CE-OmkarPathak 9 місяців тому +1

    God of explanation

  • @bhagirathmakwana9112
    @bhagirathmakwana9112 2 місяці тому +1

    You are great bro👍👍

  • @pranavmaiya4386
    @pranavmaiya4386 2 місяці тому +1

    goated explanation man thanks

  • @subhajitdey135
    @subhajitdey135 9 місяців тому +2

    Loved it bhaiya. Thank you !!

  • @jeehub041
    @jeehub041 9 місяців тому +1

    Maja aa gaya sir. Gajab approach ha

  • @AdityaGoswami-l6e
    @AdityaGoswami-l6e 9 місяців тому

    Very well explained . Thanks for what you do

  • @Akashkumar_12
    @Akashkumar_12 9 місяців тому +2

    Best explanation bhaiya thank you so much ❤

  • @thefinalfit
    @thefinalfit 9 місяців тому +1

    You made it so easy 👌🏻

  • @fshimcds
    @fshimcds 9 місяців тому +1

    Best Explanation ever thankyou so much

  • @ravneetsingh6131
    @ravneetsingh6131 9 місяців тому

    Different level explanation🔥🔥

  • @mdsharique2426
    @mdsharique2426 9 місяців тому +1

    Love your solution sir!

  • @DevOpskagyaan
    @DevOpskagyaan 9 місяців тому

    Legit explanation

  • @aws_handles
    @aws_handles 9 місяців тому

    Was able to code it when you told the pattern. thanks a lot

  • @kapilnitb
    @kapilnitb 9 місяців тому +2

    well explained!! mja aa gya

  • @gauravbanerjee2898
    @gauravbanerjee2898 9 місяців тому

    Thanks a lot bhaiya ❤❤

  • @munish008
    @munish008 9 місяців тому +2

    Another Approach : we can also replace all numbers which are less than or equals to 0 ( 0) {
    return i + 1;
    }
    }
    return (N + 1);
    }
    }

  • @manimanohar_001
    @manimanohar_001 9 місяців тому

    All newcomers just stick with this channel for 2 to 3 months. U will surely see a change in you 😎.

  • @ankitris5201
    @ankitris5201 9 місяців тому +1

    well explained bro🙏🙏.

  • @gui-codes
    @gui-codes 9 місяців тому

    great explanation man.

  • @shivamrastogi8146
    @shivamrastogi8146 9 місяців тому

    I think a simpler solution can be implemented if just shift all the elements

  • @nawazthezaifre8870
    @nawazthezaifre8870 9 місяців тому +1

    Osm Explanation !

  • @BiswajitDas-lk7pp
    @BiswajitDas-lk7pp 9 місяців тому +1

    Amazing Explanation ❤

  • @AmarjeetKumar-to9ub
    @AmarjeetKumar-to9ub 9 місяців тому +1

    Thank You :)

  • @vishalgarna12
    @vishalgarna12 3 місяці тому +2

    ❤❤❤

  • @aditimahabole1761
    @aditimahabole1761 9 місяців тому +1

    the great great great person.

  • @keshavkarn173
    @keshavkarn173 9 місяців тому +1

    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.

    • @codestorywithMIK
      @codestorywithMIK  9 місяців тому +1

      Actually really occupied in my new office. Will soon work on this ❤️

  • @abhaysinghm7643
    @abhaysinghm7643 9 місяців тому +2

    Bhaiya ❤️ GFG POTD v solve kra do daily 🙏🙏❤aapke wjh se DSA me ekdm se interest aa gya h bhaiya ❤️

    • @codestorywithMIK
      @codestorywithMIK  9 місяців тому +2

      Actually i gets difficult because of office. Will try my best ❤️❤️❤️

  • @EB-ot8uu
    @EB-ot8uu 9 місяців тому

    It's clear now why people call you legend everywhere

  • @sanjaykatta6499
    @sanjaykatta6499 9 місяців тому +1

    Awesome!!

  • @akshaychavan5511
    @akshaychavan5511 9 місяців тому +4

    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.

    • @codestorywithMIK
      @codestorywithMIK  9 місяців тому +2

      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

    • @akshaychavan5511
      @akshaychavan5511 9 місяців тому +1

      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.

    • @dsayembai_00
      @dsayembai_00 9 місяців тому

      I just started following my bro yesterday and based on the yesterday's problem i solved todays problem. Really gem👨‍🏫

  • @dhairyachauhan6622
    @dhairyachauhan6622 9 місяців тому +1

    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

  • @abhishekkumarsingh97
    @abhishekkumarsingh97 9 місяців тому

    Nice video brother. Very easy to understand.
    Can it be solved with linear time and constant space complexity without modifying the array ?

  • @chitranshjain9714
    @chitranshjain9714 9 місяців тому +1

    Bhaiya kya approach hai🫡🫡
    Please make a video on leetcode 2935(maximum strongest pair xor II)

  • @tutuimam3381
    @tutuimam3381 9 місяців тому +1

    Thanks ❤❤❤❤❤❤

  • @molyoxide8358
    @molyoxide8358 9 місяців тому

    Request : Bring BIT Manipulation playlist soooooooon. Want to learn only from you waiting from past 1 yr.

    • @codestorywithMIK
      @codestorywithMIK  9 місяців тому

      Sure thing. Just a little occupied at my new office. Will soon start working on that ❤️

    • @molyoxide8358
      @molyoxide8358 9 місяців тому

      @@codestorywithMIK Have you shifted from the current company??

  • @aditya_yt0
    @aditya_yt0 9 місяців тому

    Should we consider space complexity O(1) as we're indeed using the given O(n) space for solving the problem?

    • @codestorywithMIK
      @codestorywithMIK  9 місяців тому +1

      The input space is not considered in calculating Space complexity

  • @madhurjyadoley3100
    @madhurjyadoley3100 9 місяців тому

    Hi Sir, can you please make a video on the problem..
    Set matrix zeros.
    Leetcode No 73.
    Thank You in advance.

  • @adityachaturvedi4369
    @adityachaturvedi4369 9 місяців тому +1

    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?

    • @codestorywithMIK
      @codestorywithMIK  9 місяців тому +1

      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.

  • @abhisheksinghrajput2624
    @abhisheksinghrajput2624 9 місяців тому +1

    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.

    • @codestorywithMIK
      @codestorywithMIK  9 місяців тому +1

      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

    • @abhisheksinghrajput2624
      @abhisheksinghrajput2624 9 місяців тому

      @@codestorywithMIK ya correct

  • @gp7060
    @gp7060 9 місяців тому

    Sir please make video on dinic’s algorithm and meet in the middle algorithm.

  • @ankitachaturvedi2822
    @ankitachaturvedi2822 9 місяців тому +1

    Sir please make a video on Rabin Karp Algorithm..🙃

    • @codestorywithMIK
      @codestorywithMIK  9 місяців тому +2

      Let me plan soon this weekend

    • @lofireverbz-wy7go
      @lofireverbz-wy7go 9 місяців тому +1

      yes bhaiya waiting since too long@@codestorywithMIK

    • @ankitachaturvedi2822
      @ankitachaturvedi2822 9 місяців тому

      Thank you for the response@@codestorywithMIK , I'll be eagerly waiting :)

  • @piyushmalviya6543
    @piyushmalviya6543 9 місяців тому

    bhaiya also make videos on GFG PODT problems daily

    • @codestorywithMIK
      @codestorywithMIK  9 місяців тому +1

      Currently occupied with office. Will soon plan

  • @anushkathakur6531
    @anushkathakur6531 9 місяців тому

    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...

    • @codestorywithMIK
      @codestorywithMIK  9 місяців тому

      Yes but time completely will be more than O(n)

  • @SohailKhan-cx9gb
    @SohailKhan-cx9gb 9 місяців тому +1

    Bhaiya how to ask for hints in interview can you give us example

    • @codestorywithMIK
      @codestorywithMIK  9 місяців тому +1

      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.

    • @SohailKhan-cx9gb
      @SohailKhan-cx9gb 9 місяців тому

      @@codestorywithMIK thankyou sir

  • @manas_thakre
    @manas_thakre 9 місяців тому

    sir notes link please

    • @codestorywithMIK
      @codestorywithMIK  9 місяців тому

      iPad PDF Notes - github.com/MAZHARMIK/Interview_DS_Algo/blob/master/iPad%20PDF%20Notes/Leetcode-41-First%20Missing%20Positive.pdf

  • @priyanshu5407
    @priyanshu5407 9 місяців тому +1

    bhai qusion tosa hard to ha or

  • @MonuKumar-mf9my
    @MonuKumar-mf9my 9 місяців тому

    Bhaiya apse baat karni hai number milega kya apka