Find the Longest Substring Containing Vowels in Even Counts - Leetcode 1371 - Python

Поділитися
Вставка
  • Опубліковано 16 гру 2024

КОМЕНТАРІ • 67

  • @varane27
    @varane27 3 місяці тому +59

    this should be HAAAARD! No way I could solve this in an interview without some hints.

  • @RockStarPunk0
    @RockStarPunk0 3 місяці тому +45

    19:28 thanks for remainding me

  • @mohammadaminkhaje8224
    @mohammadaminkhaje8224 3 місяці тому +56

    girlfriend -> doesn't make you better leetcode
    neetcode -> makes you better at leetcode
    conclusion: neetcode wins

    • @Tab-It
      @Tab-It 3 місяці тому +13

      Make neetcode your girlfriend

    • @sudesh6807
      @sudesh6807 3 місяці тому

      Good. now are expert at leetcode and u will die single

    • @pravyn350
      @pravyn350 3 місяці тому

      Yeah 😂

    • @sidazhong2019
      @sidazhong2019 15 днів тому

      girlfriend makes you worse at leetcode

  • @harshitjain8820
    @harshitjain8820 3 місяці тому +11

    Didn't even had to watch the coding part, just soo good! 🔥🔥🔥🔥

  • @minaFbeshay
    @minaFbeshay 3 місяці тому

    23:48 you can even remove the "else" keyword, after swapping the two conditions
    for (int i =0; i< s.length(); i++){
    char c = s.charAt(i);
    mask = mask ^ vowels.getOrDefault(c, 0);
    if (map[mask] == -1 && mask != 0)
    map[mask] = i;
    ans = Math.max(i - map[mask], ans);
    }

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

    This should definitely be a hard problem, no way I'd come up with this solution on the spot, and i started with assembly back in the days. Thanks for the great and clear explanation, as always

  • @baetz2
    @baetz2 3 місяці тому +27

    19:28 My wife doesn't allow me to have a girlfriend, so I'm watching

    • @mohd.tabishkhan4868
      @mohd.tabishkhan4868 3 місяці тому +3

      man you gotta do leetcode even after marriage, damn i am sad now. Life is hard
      im just in college rn

    • @ewiz_0262
      @ewiz_0262 3 місяці тому

      No way

  • @vrajrana2175
    @vrajrana2175 3 місяці тому +20

    19:28 trolled me : ❌
    Trolled Himself : ✅

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

    if someone asks you to use bit operations in an interview - they don't want you to work there

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

    thank you i would have never got the solution if it wasn't for you

  • @aryansuvarna4923
    @aryansuvarna4923 3 місяці тому +1

    what an insane solution. well played

  • @DhanushBRaj
    @DhanushBRaj 3 місяці тому +1

    From 19:28.... I'm still watching in loop...!

  • @guitarfanatics77
    @guitarfanatics77 3 місяці тому +8

    ​ @NeetCodeIO this is so hard for someone like me who never solve a bitmask problem before, and I just checked the problems with bitmask tag on leetcode and they are all medium difficulty. Is there any easier problem for noob like me to practice bitmask?

    • @NeetCodeIO
      @NeetCodeIO  3 місяці тому +8

      Here's one we solved this week: ua-cam.com/video/CFa2TgIHMN0/v-deo.html

  • @harshugamer7776
    @harshugamer7776 3 місяці тому +4

    19:24 , I am watching

  • @shauryatomer1058
    @shauryatomer1058 3 місяці тому

    thanks for this great explanation

  • @IamAbhiinav
    @IamAbhiinav 3 місяці тому +1

    LeetCode cooked with this one

  • @MP-ny3ep
    @MP-ny3ep 3 місяці тому

    Thank you so much !

  • @matalamedo
    @matalamedo 3 місяці тому

    For all of y'all who feel bad for being unable to solve this one, don't. This should've been a hard problem.

  • @darshanrokkad5216
    @darshanrokkad5216 3 місяці тому

    thank you

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

    Surely this is hard

  • @khatora
    @khatora 3 місяці тому +1

    can anyone explain how this is right mask^=(1+ord(c)-ord('a));
    I think it should be like this flib the bit corresponding to the character mask ^= (1

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

    i've no idea. I don't think i can get to FAANG.

    • @testAccount-eb2ve
      @testAccount-eb2ve 3 місяці тому +1

      Right now you may not, but with patience and practise you can 😃

  • @taozhaojun
    @taozhaojun 3 місяці тому +11

    I don't have a girlfriend🤣

    • @NeetCodeIO
      @NeetCodeIO  3 місяці тому +26

      that's why i'm here friend 🫂

    • @taozhaojun
      @taozhaojun 3 місяці тому +1

      it is more clear to write mask ^= (1

    • @NeetCodeIO
      @NeetCodeIO  3 місяці тому +9

      damn you're write, clever.

    • @pravyn350
      @pravyn350 3 місяці тому

      @@NeetCodeIO😂 can you act as my GF too !

  • @venkatgaddam6587
    @venkatgaddam6587 3 місяці тому +1

    This is definitely not a medium question!!!.

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

    I have a gf that is why I did not look at the second solution,thanks Neetcode

  • @buckwheatplate8770
    @buckwheatplate8770 3 місяці тому

    I'm gonna have a long walk after this...

  • @NandanUpadhyay-w2f
    @NandanUpadhyay-w2f 3 місяці тому

    Can we actually code hashMap soln ??

    • @NeetCodeIO
      @NeetCodeIO  3 місяці тому +1

      Yeah but would probably need to serialize the hashmap into a string. Also should probably just use a hash set rather than a map, I just drew a map because the mapping makes it easier to visualize

  • @romanivanov6183
    @romanivanov6183 3 місяці тому

    Why do we need this bitmask? Why not just simple dictionary?

  • @BootBoot-rl1kv
    @BootBoot-rl1kv 3 місяці тому +1

    day by day why coders are becoming trollers

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

      Solving these gets boring sometimes, just trying to entertain myself tbh

    • @BootBoot-rl1kv
      @BootBoot-rl1kv 3 місяці тому

      @@NeetCodeIO 😂😂 i understand

  • @shikher4559
    @shikher4559 3 місяці тому

    I watched the complete video which means i dont have a ....

  • @sauravsingh4497
    @sauravsingh4497 3 місяці тому

    i tried the sliding window solution by storing the rightmost index of every vowel in the string but it didn't work

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

      yeah i believe i explained why it doesnt work

    • @sauravsingh4497
      @sauravsingh4497 3 місяці тому

      @@NeetCodeIO yep thank you for such a great explaination

  • @ChetanAnnam
    @ChetanAnnam 3 місяці тому

    Most confusing and difficult

  • @ewiz_0262
    @ewiz_0262 3 місяці тому +1

    Nah, I'd leave

  • @yang5843
    @yang5843 3 місяці тому

    Don't see why people are calling this problem a hard, you can use prefix sum and solve this as a medium at best

    • @thepriestofvaranasi
      @thepriestofvaranasi 3 місяці тому

      Can you please elaborate on how prefix sum is used for this problem? Thanks.

    • @yang5843
      @yang5843 3 місяці тому

      ​​@@thepriestofvaranasiso you iterate left to right for each char of the array, if you are currently at an odd number of vowels, and you encounter the same set of odd vowels before, then you know odd - odd = even, I'm simplifying my explanation a bit but you're basically keeping track of the occurrences of each vowel as you iterate through the array

    • @hadizorkot2889
      @hadizorkot2889 3 місяці тому

      ​@@yang5843so basically what he just explained but worse

  • @pruthvinarayana9568
    @pruthvinarayana9568 3 місяці тому

    hey Neetcode , why do you look like an indian?

    • @NeetCodeIO
      @NeetCodeIO  3 місяці тому +7

      that's a LC easy.. I'm sure you can figure it out :)

    • @pruthvinarayana9568
      @pruthvinarayana9568 3 місяці тому

      @@NeetCodeIO Huge respects , Thanks for carrying us ❤

  • @immortal4091
    @immortal4091 3 місяці тому

    Neetcode -> If you don't have a girlfriend, keep watching
    Me -> Watching bro, you don't have to point it out🥲🥲