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); }
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
@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?
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
@@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
this should be HAAAARD! No way I could solve this in an interview without some hints.
yeah it's pretty tricky dicky
@@NeetCodeIO💀
@@NeetCodeIO "dick"y
𝓕𝓻𝓮𝓪𝓴CodeIO
@@brij4887 lmaooo
19:28 thanks for remainding me
girlfriend -> doesn't make you better leetcode
neetcode -> makes you better at leetcode
conclusion: neetcode wins
Make neetcode your girlfriend
Good. now are expert at leetcode and u will die single
Yeah 😂
Didn't even had to watch the coding part, just soo good! 🔥🔥🔥🔥
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);
}
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
19:28 My wife doesn't allow me to have a girlfriend, so I'm watching
man you gotta do leetcode even after marriage, damn i am sad now. Life is hard
im just in college rn
No way
19:28 trolled me : ❌
Trolled Himself : ✅
what an insane solution. well played
@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?
Here's one we solved this week: th-cam.com/video/CFa2TgIHMN0/w-d-xo.html
From 19:28.... I'm still watching in loop...!
thank you i would have never got the solution if it wasn't for you
19:24 , I am watching
if someone asks you to use bit operations in an interview - they don't want you to work there
thanks for this great explanation
thank you
For all of y'all who feel bad for being unable to solve this one, don't. This should've been a hard problem.
LeetCode cooked with this one
Surely this is hard
Thank you so much !
I don't have a girlfriend🤣
that's why i'm here friend 🫂
it is more clear to write mask ^= (1
damn you're write, clever.
@@NeetCodeIO😂 can you act as my GF too !
i've no idea. I don't think i can get to FAANG.
Right now you may not, but with patience and practise you can 😃
This is definitely not a medium question!!!.
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
Can we actually code hashMap soln ??
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
I have a gf that is why I did not look at the second solution,thanks Neetcode
My man
I'm gonna have a long walk after this...
Why do we need this bitmask? Why not just simple dictionary?
i tried the sliding window solution by storing the rightmost index of every vowel in the string but it didn't work
yeah i believe i explained why it doesnt work
@@NeetCodeIO yep thank you for such a great explaination
Most confusing and difficult
day by day why coders are becoming trollers
Solving these gets boring sometimes, just trying to entertain myself tbh
@@NeetCodeIO 😂😂 i understand
Nah, I'd leave
I watched the complete video which means i dont have a ....
Don't see why people are calling this problem a hard, you can use prefix sum and solve this as a medium at best
Can you please elaborate on how prefix sum is used for this problem? Thanks.
@@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
@@yang5843so basically what he just explained but worse
hey Neetcode , why do you look like an indian?
that's a LC easy.. I'm sure you can figure it out :)
@@NeetCodeIO Huge respects , Thanks for carrying us ❤
Neetcode -> If you don't have a girlfriend, keep watching
Me -> Watching bro, you don't have to point it out🥲🥲