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; }
now i've watched your videos to the point that i hit like as soon as the video starts and then start watching it😂same as what i do with striver because i KNOW it's going to be epic🌟
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
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
Thanks I found your explanation somehow easier from neetcode videos
The way you explain ideas is like watching a Bollywood movie; it's very engaging.
very basic fact used by so many descriptions for this problem online but no one explained the crux of why the n-1 filler is considered. Thanks!
Because they themselves dont know, they just copy paste the solutions and post a video on it
best youtuber for leetcode , clean explainations with most optimzied codes !! god bless u bro!!
Thank you so much , I was struggling with this problem even when looking at the editorial.
your explanation is too good to be honest
Bhai for the POTD came back, nostalgia hit hogya. laut aao aryan bhaiya
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!
This is a great solution , very nicely explained
brute force approach
long long ans=x;
for(int i=0;i
now i've watched your videos to the point that i hit like as soon as the video starts and then start watching it😂same as what i do with striver
because i KNOW it's going to be epic🌟
Nice explanation
Cool Solution Dude :)
bro should have 10 times more subs
best video on entire earth
Keep going bro.
love u sir, nice explanation.
so well explained
Very good video
Bhaiya next video kab aayegi😢
haa here we go again
we want you bro please come and teach us again
Yes sir, am back ❤️❤️🫡
Awesome explanation bro!! Can you pls solve 3134 also?
why are we not sotring the bits in reverse order ? don't we convert the number from LSB to MSB
@aryanmittal can we apply binary search on answer on this question??
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;
Intuition ban gya tha , but implement ni hua :/
nice 1
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 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
I give up on coding
👌
Thanks
wow
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
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
tu hi bachata hai last me
nhi smjha'
bhai kuch samaj nhi aaya 😢
Sahi me. Sab upar se gya.
while(until don't get it) {
repeat_the_video()
}
Uff@@panapatre9855
lol