3133. Minimum Array End | Bit Interweaving | Bit Interleaving | Bit Manipulation | 2 Pointers
Вставка
- Опубліковано 26 кві 2024
- In this video, I'll talk about how to solve Leetcode 3133. Minimum Array End | Bit Interweaving | Bit Interleaving | Bit Manipulation | 2 Pointers
Let's Connect:
📱Discord (Join Community) : / discord
📝Linkedin: / aryan-mittal-0077
📸 Instagram: / ez.pz.dsa
💻 Twitter - / aryan_mittal007
🤖 Github: github.com/aryan-0077
About Me:
I am Aryan Mittal - A Software Engineer in Goldman Sachs, Speaker, Creator & Educator. During my free time, I create programming education content on this channel & also how to use that to grow :)
✨ Hashtags ✨
#programming #Interviews #leetcode #faang #maang #datastructures #algorithms
The way you explain ideas is like watching a Bollywood movie; it's very engaging.
best youtuber for leetcode , clean explainations with most optimzied codes !! god bless u bro!!
Cool Solution Dude :)
best video on entire earth
so well explained
This is a great solution , very nicely explained
love u sir, nice explanation.
Keep going bro.
Thank you so much for the video.
There can be a easy solution for this as well:
Increasing the unset bits:
long long minEnd(int n, int x)
{
long long a = x;
n--;
while(n--)
{
a=(a+1)|x;
}
return a;
}
Thanks for getting me a TLE !
Not optimal though
@@akshatsingh6036 it wont bro!
Thanks
nice 1
👌
Awesome explanation bro!! Can you pls solve 3134 also?
nBit[i] should be equal to ((n-1)>>1)&1 na instead of (n>>1)&1 as You have taught the same thing at 12:39
I give up on coding
@aryanmittal can we apply binary search on answer on this question??
Easiest code:
class Solution {
public:
long long minEnd(int n, int x) {
long long ans=x;
long long k=n-1;
for(int i=0;i
I understood the logic..but i didn't get the intuition why n-1 number only we have to do the 2 pointer thing..like is there any concept behind
When setting xbit[i] and nbit[i] I used
xbit[i] = x & (1 i) & 1
(n >> i) & 1
Let us say you want to know existence of 2nd bit i.e for a number 4, which has binary representation as 100, then your code will say xbit[2] = 4 while, you wanted to know just that if that 2nd bit was set or not, which means you wanted xbit[2] = 1, xbit will have only 2 values 0 or 1, saying if some bit was set or not
@@ARYANMITTALoh accha 😅😅 understood thankyou ❤❤
@@ARYANMITTAL int se & krne pr int me convert ho jata hai no?
or 1 se krne pr binary me rehta hai?
You can also do this
xbit[i]=x&1;
x>>=1;
nbit[i]=n&1;
n>>=1;
Why my code is giving me wrong ans for 56 testcases ?
public long minEnd(int n, int x) {
int j = 0;
long ans = (long)x;
for(int i=0; i> i) & 1);
if(bit == 1) continue;
if((1 n-1) break;
int newBit = (((n-1) >> j) & 1);
j++;
if(newBit == 0) continue;
ans |= (newBit
Intuition ban gya tha , but implement ni hua :/
bhai kuch samaj nhi aaya 😢
Sahi me. Sab upar se gya.
while(until don't get it) {
repeat_the_video()
}
Uff@@panapatre9855