Lecture 7: LeetCode Problem Solving Session

  Рет қаралды 824,043

CodeHelp - by Babbar

CodeHelp - by Babbar

Күн бұрын

Пікірлер: 1 500
@himadridas8221
@himadridas8221 Жыл бұрын
When this man says, "samajh mein aa geya?, Chalo phirse samajhte hain", it gives a different kind of satisfaction ❤
@shubh1373
@shubh1373 Жыл бұрын
I have an doubt in first question that we had not defined any INT_MAX or INT_MIN so how can problem figure out meaning of these two some one please help
@himadridas8221
@himadridas8221 Жыл бұрын
​@shubh1373 I am trying to understand your problem...INT_MAX or INT_MIN are not defined so how the code is being processed right ? These are called macros ...they initially hold the minimum or maximum values of an integer.. these are predefined.
@shubh1373
@shubh1373 Жыл бұрын
@@himadridas8221 thanks a lot bro cleared my doubt
@BadalJena-oh6qu
@BadalJena-oh6qu Жыл бұрын
bro can you give a review of this course like there are other dsa resources like pep coding and pw. Is this course good enough.
@himadridas8221
@himadridas8221 Жыл бұрын
@BadalJena-oh6qu look, I haven't completed this course, but I have watched some videos of this playlist, and came to know he is a fabulous teacher, who teaches you everything by holding your hand. So I would say if you want to learn DSA deeply you can follow this course, explanation will be top notch. Else if u want you can take his paid course of DSA which is yet to start
@zaeemAtif
@zaeemAtif 2 жыл бұрын
Thank you bhaiya, don't know if you are even reading this comment or not, but just wanna say, the process you are teaching for solving quetions is waayyy more important and efficient than any course or youtube video I have watched. I definitely believe, this series is going to be a game changer.
@tripuraridev5415
@tripuraridev5415 2 жыл бұрын
yes you are right.....
@nimrahasghar8955
@nimrahasghar8955 Жыл бұрын
1000% right
@hilariouschannel322
@hilariouschannel322 Жыл бұрын
Kitne vedios kr chuke ho xaiem bhai ?😅 Kaif
@newhope5729
@newhope5729 Жыл бұрын
bitwiseComplement(int n) { int nob=0,k=n; while(k!=0){ k=k>>1; nob++; } if(nob==0) return 0; int t=32-nob; k=INT_MAX^n; int l=INT_MAX>>t; n=l&&k; return n; Bhai isme kya prblm hai..... Question 2 ka code..... YE answer galat de rha par dry run karke dekho to sahi deta answer
@newhope5729
@newhope5729 Жыл бұрын
bool isPowerOfTwo(int n) { if(n==1) return true; int m=32; unsigned long k=pow(2,31); n=~n; while(m!=0) { n=n>>1; n=n|k; if(n==(INT_MAX-1)) return true; m--; } return false; } Bhaiya this is question 3.... What's the error?? It is giving false on problem 3.......
@visheshkaran7083
@visheshkaran7083 2 жыл бұрын
Bhaiya seriously you are doing a lot of work for the community. I'll also contribute a lot like you in future and thanks thanks a lot!!!
@newhope5729
@newhope5729 Жыл бұрын
bitwiseComplement(int n) { int nob=0,k=n; while(k!=0){ k=k>>1; nob++; } if(nob==0) return 0; int t=32-nob; k=INT_MAX^n; int l=INT_MAX>>t; n=l&&k; return n; Bhai isme kya prblm hai..... Question 2 ka code..... YE answer galat de rha par dry run karke dekho to sahi deta answer
@newhope5729
@newhope5729 8 ай бұрын
@rohitshaw-vd9lq Chhod diya bhai discontinue kar diya mai
@newhope5729
@newhope5729 8 ай бұрын
@rohitshaw-vd9lq Kuchh na bhai mai core electronics kar rha becoz iska abhi itna jaldi sab prepare ni ho payega iske liye 6 mahina bhar chahiye hota hai na mere ko time ni milta tha
@ankitdaidanka9165
@ankitdaidanka9165 2 жыл бұрын
I have done the power of 2 question using bit and right shift it was much easier instead. First question till now in this series which built my confidence as I was able to think out of the box. Thanks.
@newhope5729
@newhope5729 Жыл бұрын
bool isPowerOfTwo(int n) { if(n==1) return true; int m=32; unsigned long k=pow(2,31); n=~n; while(m!=0) { n=n>>1; n=n|k; if(n==(INT_MAX-1)) return true; m--; } return false; } Bhaiya this is question 3.... What's the error?? It is giving false on problem 3.......
@aryyann05
@aryyann05 2 ай бұрын
can u provide the solutiuon?
@anuradhajadon4827
@anuradhajadon4827 2 жыл бұрын
Marked my attendance. loving the content.
@apurvaparanjape8940
@apurvaparanjape8940 2 жыл бұрын
Can u tell me how to mark the attendance
@shubhambansal1495
@shubhambansal1495 2 жыл бұрын
@@apurvaparanjape8940 video ko like karke
@apurvaparanjape8940
@apurvaparanjape8940 2 жыл бұрын
@@shubhambansal1495 ok thanks
@rameshmalhotra9525
@rameshmalhotra9525 2 жыл бұрын
kzbin.info/www/bejne/qnK0en6bZbp6fpY
@IT-gw9rf
@IT-gw9rf Жыл бұрын
Mujhse homework questions kyu nhi hote yrr😓
@rahulkumarsingh7615
@rahulkumarsingh7615 2 жыл бұрын
In the last question of power of 2, U can also use bit property...........If(n & n-1 ==0) then it is a power of 2..
@musicx5856
@musicx5856 2 жыл бұрын
Can you explain !!
@shivu848
@shivu848 2 жыл бұрын
Loved it bhaiya . We need more videos of leetcode questions discussion. I am a beginner in leetcode. By seeing your video i got the insight of how to approach a problem in leetcode. you are doing a great work..🙌
@newhope5729
@newhope5729 Жыл бұрын
bool isPowerOfTwo(int n) { if(n==1) return true; int m=32; unsigned long k=pow(2,31); n=~n; while(m!=0) { n=n>>1; n=n|k; if(n==(INT_MAX-1)) return true; m--; } return false; } Bhaiya this is question 3.... What's the error?? It is giving false on problem 3.......
@RajatAswani
@RajatAswani Жыл бұрын
ENJOYED!!! Being Honest, Quite fast, but the way he revises everything after submitting, it helps a lot and if you still don't get the concept, watch it repeatedly 2-3 times, you''ll get it. Completed on 10-11-2022 (21:22 pm).
@shubhamuniyal9047
@shubhamuniyal9047 2 жыл бұрын
MOST NEEDED VIDEO BROTHER❤️, WITHOUT DOING ACTUAL CODING, ONE CANNOT LEARN MUCH FROM IT :)
@fatimasohail3027
@fatimasohail3027 Жыл бұрын
@shubhamuniyal9047 Why we write ans>int-Max/10?
@PrakashKumar-xf7qf
@PrakashKumar-xf7qf Жыл бұрын
@@fatimasohail3027 because it goes beyond the last limit.
@khushijain7689
@khushijain7689 2 жыл бұрын
You explain that range part of problem in such easy words 🔥🔥
@deepanshusaini353
@deepanshusaini353 2 жыл бұрын
Maza aa rha hai lekin mujhse ho nhi rhe
@Tej014
@Tej014 8 ай бұрын
Day : 7 attendance mark
@sarcasmaursocial7331
@sarcasmaursocial7331 8 ай бұрын
day 2
@anishgujja3669
@anishgujja3669 4 ай бұрын
keep going buddy
@anishgujja3669
@anishgujja3669 4 ай бұрын
Bro I have few doubts. Can we make a group or something like that to discuss our doubts. Share your insta I'd or something or just reply to this msg anyone who is reading
@raunakbaliyan9918
@raunakbaliyan9918 4 ай бұрын
@@anishgujja3669 yes bro sure
@GUNGUNLASTNAME
@GUNGUNLASTNAME 3 ай бұрын
​@@anishgujja3669 we will make telegram group for discussion
@moutamarakshit
@moutamarakshit Жыл бұрын
bhaiya, i did the complement one with XOR :) mask = 0000....111 and then int ans = n ^ mask; kitna achchha laga jab sahi hua haha :)
@AMIT-bf2id
@AMIT-bf2id 2 жыл бұрын
POWER OF TWO I have used binary digits to find solution , in binary number system 1 = 01 2 =10 4 = 100 8 = 1000 16 = 10000 My approach is I have converted n into binary string and checked if 1 appear excatly once public boolean isPowerOfTwo(int n) { int count = 0; if(n == 1) return true; if(n < 0) return false; String bin = Integer.toBinaryString(n); // int h = Integer.parseInt(bin); for(int i=0 ;i< bin.length();i++) { if(bin.charAt(i) == '1') count++; } if(count == 1) return true; else return false; } }``
@anshbhatia9823
@anshbhatia9823 2 жыл бұрын
Here instead of checking count for 1, you can also check that no bit until the first is 1 and return false immediately if so(by checking last bit and then performing right shift until n becomes just 1)
@itzmranonymous
@itzmranonymous Жыл бұрын
@@anshbhatia9823 yup nice logic 🔥, but then too we will have to check whether solution is equal to 1 or not.
@scientistakasha7293
@scientistakasha7293 21 күн бұрын
Ansh bhatia...you meant that start from the right most bit then decrement i?? If yes then yeah it will take lesser iterations and program will be faster
@probably_yj
@probably_yj 2 жыл бұрын
My approach to the power of two question . I used the remainder of the division to check if the number is a power of two or not. Any Number which is power of two will always return n%2 = 0 till the end (except 0 and 1). So i ran a while loop till remainder is 0 . if we get remainder 0 till end then its power of 2 , else if we dont get 0 as remainder at any iteration then it will return false.. BTW , aapke videos bahut acche h Babbar bhaiya. Itne time se padhai me mazza nahi aaya tha mujhe :) class Solution { public: bool isPowerOfTwo(int n) { bool result ; while(n!=0){ int rem = n%2; if(rem==0){ n = n/2; } else if(rem!=0){ result = false; break; } result = true; } if(n==0){ result = false; } if(n == 1){ result = true; } return result; } };
@debjitghorai9503
@debjitghorai9503 9 ай бұрын
easier way to do complement of base 10 integer:- (let n = 5); int num = 0; int i = 0; while (n!=0) { int bit,rev; bit = n & 1; // finding each bit of 5 i.e. 101 rev = bit ^ 1; // taking xor of each bit with one, which turns it into complementary (1xor1=0. & 0xor 1 = 1) n = n>>1; if (rev == 1) { num = pow(2,i)*rev + num; } i = i + 1; } return num; the xor operator turns 101(binary of 5) to 010(complement). and the num gives us output = 2;
@piupiu634
@piupiu634 3 ай бұрын
Nah bro .. even i thought abt this.. but this thing will count the 1s too..which aarent required... and then the result will be very big number
@aashishrangdal9614
@aashishrangdal9614 2 жыл бұрын
Loving The Content🔥🔥 Babbar Bhaiya Is Getting Blessed Of Students Wishesh😍
@vikashchoudhary7666
@vikashchoudhary7666 2 жыл бұрын
Day 4 after starting first video, I'm fan of your teaching. thanks alot for this course. Right now I'm preparing for relevel DSA and I'm quite confident now at the end i can give my 100% learning in test
@revantsinha1672
@revantsinha1672 Жыл бұрын
this is my code for last question . bahut jayad simple simple socha😅😅 class Solution { public: bool isPowerOfTwo(int n) { bool istrue = true; if(n==1){ return true; } if(n
@aryanisgood
@aryanisgood Ай бұрын
the last question can also be solved using this algorithm: all numbers that are powers of 2, have only one '1'in their binary form. eg 4 has 100, 32 has 10000, 8 has 1000. so we can run a loop and check the number of 1's in the number, if count ==1, then it is a power of 2 as '1' has appeared only once
@sparshgamer1582
@sparshgamer1582 6 күн бұрын
Can you provide the code?
@sameershaik5324
@sameershaik5324 2 жыл бұрын
We can also do power of 2 using log concept class Solution { public: bool isPowerOfTwo(int n) { if(n
@youcube1
@youcube1 6 ай бұрын
😮😮
@HarshKumar-mx9nj
@HarshKumar-mx9nj Жыл бұрын
alternate approach for power of 2 question : #include using namespace std; int main (){ int n ; cout > n ; int rem = 0 , m = n ; for(;n>1;){ rem = rem + (n%2) ; n = n / 2 ; } if(rem == 0 || m == 1){ cout
@yashsinghal3136
@yashsinghal3136 Жыл бұрын
3).Power of Two as said in the video there is another way we can solve this problem that i saw in discussion of leetcode that is to And(&) bit of the given number(n) and the bit of its previous number(n-1) and if they give 0 output then that number is in power of two. Example- Case1: n=2 2 in bit format=010 and(2-1=1) in bit format =001 when we And both the bits we get =000 Case2: n=8 8 in bit format=1000 (8-1=7) in bit format=0111 when we And them it will be=000 Similarly for all the cases CODE: if(n
@AviSanX
@AviSanX Жыл бұрын
that was really beautiful and very smart, I also read the intial lines of the explanation of this code in discussion section but I was scared then and there. When I read yuor explanation, I understood it quite well and without any problem. Thanks.
@divyampatni3571
@divyampatni3571 Жыл бұрын
basically you are saying that only 1 bit out of 32 bits can be 1, to be a 2's power
@saswatrath4646
@saswatrath4646 9 ай бұрын
only if the left most bit could be 1 and rest all bit as 0 @@divyampatni3571
@aleatoire6110
@aleatoire6110 2 жыл бұрын
well the complement can also be done in a simple way but the solution of bhaiya is also pretty good class Solution { public: int bitwiseComplement(int n) { int ans=0,i=0; if(n!=0) { while(n!=0) { int bit = n&1; if(bit==1) bit=0; else bit=1; ans = ans + bit*pow(2,i); n = n>>1; i++; } return ans; } else return 1; return 0; } };
@RupeshKumar-ov5rt
@RupeshKumar-ov5rt Жыл бұрын
Thank you for all that you do. Your hard work doesn't go unnoticed. You're appreciated! thanks bhaiya 🥰
@educulture1004
@educulture1004 10 ай бұрын
36:23 qn can also be done using following logic: Since the given number would be a power of 2 so, its binary would be containing only a single bit as 1 and other as 0. Hence we can count the number of set bits in the number If count is 1 then true Otherwise false.
@Scientest2004
@Scientest2004 11 ай бұрын
Bhut maja aaya bhaiya Content badiya he bhut Aap esse hi questions example or homework me dye na Or khi bhi koi bhi Kami nhi thi Full out full focus tha aapkye lecture me Or lykin 1gante ki bajaye muje 2h+30m lag gye Or Aaj phali bar leetcode per question fod kar kafi maja aaya Me ab se phale se or aagye future me abhi aapse yu hi judi rhungi bhaiya Thanks bhaiya etana badiya content hame free me sikhne kye liye . Fee kye rup me God ji se kafi sari badiya badiya wishes aapkye liye magu gi . Or muje bhi aapki hi trh ak badi company me interview fodna he . Jariya (way of path ) muje mil hi gya aapse padh kare . Bas ab entjar ak bar me hi select hokar dikhana he Microsoft kye interview me. Interview me select hone kye bade aati hu bhaiya aapse milne . Placement achi Kashi rhi thi aapkye liye apple 🍎 ka ipade bhi laugi .mari trf se gift samje kar rhkh lye ne aap vaise bhi aapko koi gift nhi dye ta (aapne ak video me bola tha esliye muje yade tha )esliye me dugi aapko sabse acha vala gift . Thank you bhaiya. Miltye he aapse bhut jald 😃😃😃👋
@khushinegi3217
@khushinegi3217 11 ай бұрын
Ques 3: bool isPoweroftwo(int n) { //It could also be like this if(n==0) { return false; } while( n != 1) { if(n % 2 != 0) { return false; } n = n/2; } return true; }
@md.muhaiminulislam3611
@md.muhaiminulislam3611 2 жыл бұрын
Bhaiya, I am from Bangladesh. I am in first year of my varsity and really I always enjoy your content. Your contents are so much helpful for me. I am following your guidelines and practising hard and soul to get internships as well as placements in future. Keep me in your prayers.
@mlkgpta2869
@mlkgpta2869 Жыл бұрын
One of the best thing is that you know how students make mistakes. Before seeing your solution, all the tried methods by me was also shown by you, and it feels good when someone understand where students make mistakes. Great work, you not only teaches us what is the right path but also how to think, what is it the intuition. Aur aapke suggestions are too great, leetcode ka discussion is phodu.
@sarthaktrivedi8180
@sarthaktrivedi8180 11 ай бұрын
In that complement of an integer question, what I did was take the binary form of the actual number. Initialised a variable mask=1 and wrote the following code:- while((binum & mask)!= binum) { mask
@ansarisufiyan4210
@ansarisufiyan4210 2 жыл бұрын
Thank you so much bhaiya, at first when I started DSA, I thought that it is not for me, but now I am starting to have confidence in myself thanks to you.
@adityamangla4794
@adityamangla4794 2 жыл бұрын
14:56, how come you used 'INT_MIN' and 'INT_MAX' without first defining those variables?
@javacoder5351
@javacoder5351 Жыл бұрын
check this as well www.youtube.com/@maksrane100
@rana.safikhan
@rana.safikhan 2 ай бұрын
They are pre-defined
@AdityaKumar-xk8fk
@AdityaKumar-xk8fk 2 ай бұрын
because it is predefined integer class
@RohitKumar-oo8lo
@RohitKumar-oo8lo 2 жыл бұрын
BOHOT zyada mazzaaa aa rha hai bhaiya, sab samajh aa rha hai...Aap plz time pe khatam kar dena iss course ko 🙏 Amazon crack karna hai ab to kisi bhi haalat me!!
@vedantshivarkar6057
@vedantshivarkar6057 7 ай бұрын
Didi you complete the course??
@fgh427
@fgh427 2 жыл бұрын
Greatest teacher of all time... No one... literally no one is even 1% close to you..
@aasthatripathi6952
@aasthatripathi6952 2 жыл бұрын
Lecture 7 ✅ Maza aya 👍
@Rohitkumar-kg1bh
@Rohitkumar-kg1bh 8 ай бұрын
class Solution { public: bool isPowerOfTwo(int n) { int count = 0; while (n != 0) { if ((n & 1)==1) { count++; if (count > 1) break; } n = n >> 1; } if (count == 1) return true; return false; } SIR aapne bits padhaya to usi direction me soch kar ye code lagaya 15 mins se v kam lage sochne me , or jab code accept hua to bahut achha feel hua ThankYou❤
@vinitpatil4137
@vinitpatil4137 2 жыл бұрын
Bina paise ka itna badiya course, u are a legend. Udemy vale pe tik hi nhi pata hu aur expensive course afford nhi kar pata, itna acha koi bachpan me sikhata to maza aa jata. All the best, keep up the good work. Way of teaching is too good no doubt.
@manukhurana97
@manukhurana97 2 жыл бұрын
Simple 3 line java Sol: 17:40 if(n==0) return 1; int i = 0, m = 0; while(n != 0){ m += Math.pow(2, i++) * ((n & 1) == 0 ? 1 : 0); n >>= 1; } return m;
@prajwalurkude007
@prajwalurkude007 2 жыл бұрын
I able to solve 2 out of 3 problems with different approaches simultaneously with sir in the video!
@pritishanand
@pritishanand 2 жыл бұрын
*2 out of 3
@prajwalurkude007
@prajwalurkude007 2 жыл бұрын
@@pritishanand yea corrected
@fukedup1028
@fukedup1028 2 жыл бұрын
great
@aavyasingh6489
@aavyasingh6489 2 жыл бұрын
I study from so many channel ,but no one can solve a question on this level . When solving these minded question ,it exercise our brain and buildup our concept also . THANKS A LOT BHAIYA
@AmitSharma-nv2oj
@AmitSharma-nv2oj Жыл бұрын
Can you tell how he can use int max and int main without declaring them
@deadlyfury6317
@deadlyfury6317 Жыл бұрын
@@AmitSharma-nv2oj maximum range if already defined for integers... so we can use directly
@crowdmedia7815
@crowdmedia7815 2 жыл бұрын
bhaiya you r such an incredible teacher who selflessly trying this hard !
@CodeCommitC
@CodeCommitC Жыл бұрын
Another Alternative Of Power Of Two solution in Javascript: Explanation: if we see any number which is a power of two in binary format there would be only single binary bit which is 1 other must be zero. so we can simply check the count of binary 1's in the number, if it is 1 in total it means the number is power of two otherwise not , and we have to check for the edge case as well which is when the number is 0 var isPowerOfTwo = function(n) { let count=0; if(n==0) return false; while(n!==0) { let digit = n&1; if(digit) count++; if(count>1) return false; n >>=1; } return true; }; Thank you so much bhiya for this amazing series, lot of respect
@aritralahiri8321
@aritralahiri8321 2 жыл бұрын
Very much premium content . Thanks brother really appreciate the hard work .
@SumitSingh-wz3wt
@SumitSingh-wz3wt 2 жыл бұрын
This also worked int main(n){ int x=0, temp=n; while (temp>1){ temp /= 2; x++; } return pow(2,x) == n; }
@gaurijadhav9161
@gaurijadhav9161 2 жыл бұрын
for the first time i solved the 2nd problem by myself...literally soo Happy..Amazing Content!!
@user-qr1xq6cq5u
@user-qr1xq6cq5u 8 ай бұрын
Bhai party chahiye
@pragyanshandilya4015
@pragyanshandilya4015 2 жыл бұрын
Hello Babbar bhaiya recently saw your stl video, so tried that complement question with the help of vectors class Solution { public: int bitwiseComplement(int n) { int bit,binary=0,i=0; vectorv; if(n==0) return 1; else { while(n!=0) { bit=n&1; binary=bit*pow(10,i)+binary; n=n>>1; i++; } while(binary!=0) { bit=binary%10; v.push_back(bit); binary=binary/10; } reverse(v.begin(), v.end()); for(auto&it:v) { if(it==1) it=0; else if(it==0) it=1; } reverse(v.begin(), v.end()); int sum=0,s,k=0; for(auto&it:v) { s=it%10; sum=sum+s*pow(2,k); k++; } return sum; }} };
@only_for_fun1234r
@only_for_fun1234r 2 жыл бұрын
Bhai tum god ho ky??🥺🥲
@pragyanshandilya4015
@pragyanshandilya4015 2 жыл бұрын
@@only_for_fun1234r kya hua bro galat hai kya ;(
@h_a_r_s_h01
@h_a_r_s_h01 2 жыл бұрын
Bhaiya if possible can we get solution for the homework of the previous lecture + Motivate us(can be of 15-20 seconds) at the end of every lecture if possible ? " YOU'RE BEST FROM THE REST ❤️ "
@Incurabl
@Incurabl 2 жыл бұрын
Try more n more to do by yourself or in last Googling will help for sure.u can learn more this way
@Captain_Pikachu
@Captain_Pikachu 2 жыл бұрын
41:45 is question ko hm aese bhi kr skte h , agr koi number 2 ki power m express hoga to uske binary m exactly ek bar 1 aayega to hm count variable initialise kr skte h aur number ko right shift krke check kr skte h kitni bar 1 h , code: class Solution { public: bool isPowerOfTwo(int n) { if (n>1; } if (count==1){ return true; } else{ return false;} } }; // n0 (khud kiya h aur maja aaya 😎😎) bhardyash
@priyanshpatel2078
@priyanshpatel2078 2 жыл бұрын
Happy to comment it i know i am late but i started this playlist before 2 to 3 days i just give my answer of 2nd Question - 1's Complement of number With My Explanation //Complement Of Base 10 Integer /* The complement of an integer is the integer you get when you flip all the 0's to 1 and all the 1's to 0 in the binary representation for example - The integer 5 is "101" in binary representation and its complement is "010" which is the integer 2 in Base 10 Example - Input n = 5 Output - 2 */ #include #include using namespace std; int main() { int number; cout
@architbatham4261
@architbatham4261 Жыл бұрын
Bhaiya aap bohot asan bohot asan bol k question ko sahi me asan kr dete ho
@strivermonk9424
@strivermonk9424 2 жыл бұрын
Alternate solution of complement of Number using XOR Operation : class Solution { public: int findComplement(int num) { int res = num; int mask=0; while(num!=0) { num=num>>1; mask=(mask
@ghanashyam7701
@ghanashyam7701 2 жыл бұрын
Bro but the return value res^mask is in binary form right !?
@vijaymathe8346
@vijaymathe8346 Жыл бұрын
41:37 in this question we can also play with the binary representation of the number here is the two liner code... if(n
@rahul.murari
@rahul.murari 2 жыл бұрын
I have 9 year experience in IT and following you from last couple of months, your content is awesome, I believe everyone surely will achieve something from here and me also, Thanks, Kudos. Love ❤️
@AmitSharma-nv2oj
@AmitSharma-nv2oj Жыл бұрын
Can you tell how he can use int max and int main without declaring them
@random-0
@random-0 Жыл бұрын
@@AmitSharma-nv2oj in c++ these are inbuilt variables
@miaalora5707
@miaalora5707 2 жыл бұрын
Bht mza aa rha h pdne ap bhaiya bhtt acha pda rhe h
@neerajslab
@neerajslab Жыл бұрын
Bhaiya in first question why r u dividing by 10 in INT_MAX and INT_MIN? can we directly write the condition like this :- if(ans > INT_MAX || ans < INT_MIN) ?
@samialvi4226
@samialvi4226 Жыл бұрын
Mera b yhi question h apko ager mila ho iska solution to please let me know
@onkarswami
@onkarswami Жыл бұрын
To avoid termination of program due to overflow.
@pragatijain8261
@pragatijain8261 2 жыл бұрын
Reach++++ Best ever DSA series...Thanks bhaiya
@adityamangla4794
@adityamangla4794 2 жыл бұрын
At 15:00, shouldn't we use 'break' so that 'while' loop can be exited if we exceed the range?
@khatariinsaan5284
@khatariinsaan5284 Жыл бұрын
no need to break it will just return the answer
@rajneeshkhare6106
@rajneeshkhare6106 2 жыл бұрын
Power of 2: Another approach - since all numbers in powers of two have exactly one number of one's in their binary representation, we can solve it by performing and bitwise operation and counting the number of one's. class Solution { public: bool isPowerOfTwo(int n) { int count=0; if(n>1; } if(count==1) return true; return false; } };
@h_a_r_s_h01
@h_a_r_s_h01 2 жыл бұрын
Bhaiya if possible can you repeat the concepts of 7th lecture in future, actually today's lecture was quite barely understandable (especially INT_MAX/10 and INT_MIN/10 + Last Question i.e. Power of 2). Kindly take it as feedback. If possible please provide couple of questions on these concepts.
@TOMGAMING-hy9hi
@TOMGAMING-hy9hi 2 жыл бұрын
yes it was very difficult logic......
@AjaySingh-ty2wm
@AjaySingh-ty2wm 2 жыл бұрын
bro watch it again , i also didnt got in first attempt . now its clear
@arungound2011
@arungound2011 2 жыл бұрын
@@AjaySingh-ty2wm Can u solve my doubt at 15:02 Instead of ll why we didn't use && ...both condition are true right??
@word___addict8768
@word___addict8768 2 жыл бұрын
@@arungound2011 bro both conditions to kabhi true hogi hi nhi na to if ka fayda kya hua
@retro9511
@retro9511 2 жыл бұрын
@@word___addict8768 bro can you tell me what is INT_MAX ?
@abhijeetsharma7858
@abhijeetsharma7858 2 жыл бұрын
Bhaiya this is also an approach for powerOfTwo problem bool powerOfTwo(int n){ if(n==0){ return false; } while(n%2==0){ n/=2; } if(n==1){ return true; } return false; }
@abhishekagarwal4671
@abhishekagarwal4671 2 жыл бұрын
I have a doubt on Integer Reverse Question In the last iteration if ans is getting greater than INT_MAX after adding digit and in last iteration x will be 0 and it does not get into loop to check the condition...will the code work fine please explain if somebody can get my point
@masterquiz2307
@masterquiz2307 2 жыл бұрын
17:35 My approach ...SHOWING 100% FASTER class Solution { public: int bitwiseComplement(int n) { int p=2; while(p
@rohan3944
@rohan3944 9 ай бұрын
Day-1 /. 3 dec
@sakshamgupta7503
@sakshamgupta7503 9 ай бұрын
even i started
@rishurk9955
@rishurk9955 2 ай бұрын
2nd question different approach- public int bitwiseComplement(int m) { int mask = 0; int n = m; if(n==0){ return 1; } int i = 0; int ans = 0; while (n!=0){ int bit = (n&1)^1; ans = (int) (Math.pow(2,i++)*bit)+ans; n=n>>1; } return ans; }
@AbdullaVlogs
@AbdullaVlogs 2 жыл бұрын
Thanks, Bubbor Bhyya Getting too much involved while solving questions. I feel like my mind is now open too much to accept any test cases in 0ms hahaha😀
@sonumondal7798
@sonumondal7798 2 жыл бұрын
I have explored so many DSA courses on youtube but this one is next level ........No one can come close to this , I am loving it
@user-mz9yl1vn8u
@user-mz9yl1vn8u Жыл бұрын
going to college and watched your videos about dsa college is not opened yet but i started my preparation by watching your videos and are very helpfull sir
@nausheenkhan5896
@nausheenkhan5896 2 жыл бұрын
Thanks Bhaiyya..... feels so good that after watching your series, I am hopeful that I will be able to get a good grasp on data structure which i have been trying for years...Thanks a lot for giing this to community
@ahmadnadeemjb
@ahmadnadeemjb 2 жыл бұрын
Best Video On this topic on KZbin
@aniketnavele1131
@aniketnavele1131 2 ай бұрын
bro kuch nhi samaja
@Saalim_Malik
@Saalim_Malik 2 жыл бұрын
it can also be done with the help of bool for answering 'yes' or 'no' which I found easier... ////check if the no. can be expressed in the power of 2 int n; coutn; bool b = 1; for (int i = 0; i < 31; i++) { int ans = pow(2,i); if (ans == n) { b = 0; break; } } if (b == 1) { cout
@yashaditya6179
@yashaditya6179 2 жыл бұрын
instead of doing (~n) & mask we can also do n ^ mask . ' Also thanks a lot bhaiya , this series is immensely helpful !
@pawanbhatt314
@pawanbhatt314 2 жыл бұрын
thankyou for replying, i was hella confused coz I did (n ^ mask)
@VishalKumar-bj4nl
@VishalKumar-bj4nl Жыл бұрын
I know it's a bit long but it is understandable as he taught this one in his next lectures. // Starts from here. int count = 0; while(n != 0){ int bits = n & 1; if(n < 1) return false; else if(bits == 1) count++; n = n >> 1; } if(count == 1) return true; else return false; It simply states that if there only one '1' in the binary form of any input except negative no's then it will increase the count variable for one single time only otherwise returns false. Thank you.
@mohammedjunaidahmed9821
@mohammedjunaidahmed9821 2 жыл бұрын
I don't know C++. I learned dart and was planning to go for DSA using Java. Could you make this course inclusive for Java programmers as well? Otherwise we have to learn C++ also
@Khan67387
@Khan67387 7 ай бұрын
you can also do the 3rd question by using while loop class Solution { public: bool isPowerOfTwo(int n) { int i=0; while (i
@gourabdas8430
@gourabdas8430 2 жыл бұрын
Sir bohot maza ah raha h…bohot jada..sir m Mechanical background se hu….bt..aapka class kar k….m bohot sara chiz sikh giya hu.…khud se problem solved kar pa rah hu Thank u so much sir…🙏🙏🙏🙏❤️
@mrittikadey3734
@mrittikadey3734 Жыл бұрын
Vaiya awesome ..from Bangladesh 🇧🇩..I saw a lot of videos before but most of them trying to tech us how to code but you teach us how to think ,how to understand.. Respect bro..
@prithvirajpatil6802
@prithvirajpatil6802 Жыл бұрын
void reverse(int n) { while (n != 0) { int rev = n % 10; n = n / 10; cout
@priyapandey8951
@priyapandey8951 2 жыл бұрын
@Babbar Bhaiya, Power of two hum ase bhi karskte:- jitne bhi numbers 2 ke power me hai unka binary number asa hai ki usme sare bits 0 hai except ek bit joki 1 hai eg. 4=100, 8=1000,16=10000 and so on. To hum srf wo ek bit ke liye check karenge aur count variable lga kar karliya. class Solution { public: bool isPowerOfTwo(int n) { if(n>1; } if(count==1) return true; return false; } };
@_Sourav-us4ph
@_Sourav-us4ph Жыл бұрын
//Complement class Solution { public: int bitwiseComplement(int n) { if(n==0){ return 1; } int c=(int)(log(n)/log(2)); return (~n)&(int)(pow(2,c)-1); } }; //Power of 2 class Solution { public: bool isPowerOfTwo(int n) { if(n
@shubhamKumar-jg8ku
@shubhamKumar-jg8ku Жыл бұрын
Thank you bhaiya ,kbhi socha nhi tha ki coding itni achi lgegi ,ye sirf aapke pdhane ke trike se hi ho paya h,kya smjhate ho awesome.thank you so much for this series.
@_SouravRana
@_SouravRana Жыл бұрын
#include using namespace std; int main() { int n=64; int ans=1; while(ans
@yashrajgharat10
@yashrajgharat10 2 жыл бұрын
Easy way to find a compliment of a number by using the concept of binary to decimal & decimal to binary conversion int main() { int n,ans=0; coutn; int i=0; if(n==0) ans=1;//return ans =1; while(n!=0) { int bit=n&1; if(bit==1) bit=0; else bit=1; if(bit==1) ans=ans+pow(2,i); n=n>>1; i++; } cout
@aryansharma144
@aryansharma144 2 жыл бұрын
Best DSA content in KZbin ❤️🥇🔥
@khushiupadhyay5193
@khushiupadhyay5193 Жыл бұрын
sir i have solved the power of 2 problem like this: bool isPowerOfTwo(int n) { int i=0; while(pow(2,i)
@saqihere
@saqihere 8 ай бұрын
Amazing Session:)
@shreyansh_yadav
@shreyansh_yadav 2 жыл бұрын
Bhaiya last question mei ek or approach kr skte hain ki log2 le lein dono side.. n == 2^x log2(n) == x Yahan pr check krlein ki log2(n) agr sahi mei perfect integer hai to , sahi mei power of 2 hai agr log2(n) iski value float ya double mei hai to nahi hai... code : bool isPowerOfTwo(int n) { double m = log2(n); if(n == 0){ return false; } else if(floor(m) == m){ return true; } return false; }
@divyadeep7679
@divyadeep7679 2 жыл бұрын
finally....m no more worried about DSA...just have to continue watching this
@ayushkumarjha6870
@ayushkumarjha6870 2 жыл бұрын
power of two bool isPowerOfTwo(int n) { if(n1){ if(n%2==1){ return false; } n/=2; } return true; }
@tanishsolanki9277
@tanishsolanki9277 2 жыл бұрын
class Solution { public: bool isPowerOfTwo(int n) { for(int i = 0;i
@chandan.cg799
@chandan.cg799 Жыл бұрын
int bitwiseComplement(int n) { if(n==0){ return 1; } int temp = n; int bits = 0; while(n){ n=n/2; bits++; } int number = 1
@ashishmishra155
@ashishmishra155 6 ай бұрын
while(n > 1){ n = n / 2; } return n == 1; sirf itna sa code the last problem ka easy bhi hai bht aur efficient bhi
@GamingandTechChannel
@GamingandTechChannel 6 ай бұрын
Problem Power of 2 in js let n=4; while(n>1){ n=n/2; } return n===1;
@priyasharma8315
@priyasharma8315 2 жыл бұрын
Javascript Solution : 1.Reverse Integer var reverse = function(x) { let ans = 0; while(x !== 0){ let digit = parseInt(x % 10); ans = (ans * 10) + digit; if (ans < Math.pow(-2, 31) || ans > Math.pow(2, 31) - 1) return 0 x = parseInt(x/10); } return ans; };
@ritishasingh5098
@ritishasingh5098 2 жыл бұрын
Another approach to Base 10 Complement class Solution { public: int bitwiseComplement(int n) { if(n==0){ return 1; } int ans=0,i=0; while(n!=0){ int bit=n&1; if(!bit){ ans=pow(2,i)+ans; } ++i; n=n>>1; } return ans; } };
@imgroot9102
@imgroot9102 Жыл бұрын
hello bhaiya maine complement wala question usse bhi simple solution kiya wo bhi khud se kafi proud feel ho rha h ki going in the right direction.. class Solution { public: int bitwiseComplement(int n) { int i=0,ans=0,val=0; if(n==0){ val=1; } for(;n!=0;n=n/2){ int dig=n%2; if(dig==1){ dig==0; i++; } else{ dig=1; val+=pow(2,i); i++; } } return val; } };
@rpgaming757
@rpgaming757 Жыл бұрын
Thanku you bhaiya ,Bhaiya seriously you are doing a lot of work for the community. I'll also contribute a lot like you in future and thanks thanks a lot!!!
@kashishaggarwal4756
@kashishaggarwal4756 2 жыл бұрын
You explain each and every thing in a very nice manner ..... Thank you so much for your efforts brother
@pulkitgarg7021
@pulkitgarg7021 Жыл бұрын
int bitwiseComplement(int n) { // edge case if (n == 0) return 1; int i = 0; int num = 0; while(n!=0) { int bit = !(n&1); num = (pow(2, i) * bit) + num; n = n >> 1; i++; } return num; } This is also a possible solution.
Lecture 8: Switch Statement & Functions
1:24:59
CodeHelp - by Babbar
Рет қаралды 850 М.
Lecture 6: Binary & Decimal Number System
35:15
CodeHelp - by Babbar
Рет қаралды 800 М.
An Unknown Ending💪
00:49
ISSEI / いっせい
Рет қаралды 49 МЛН
Will A Guitar Boat Hold My Weight?
00:20
MrBeast
Рет қаралды 197 МЛН
GIANT Gummy Worm Pt.6 #shorts
00:46
Mr DegrEE
Рет қаралды 14 МЛН
Lecture 9: Introduction to Arrays in C++
1:29:54
CodeHelp - by Babbar
Рет қаралды 1,3 МЛН
Lecture 11:Time & Space Complexity || How to avoid Time Limit Exceeded [TLE]
29:12
How A Poor Boy Built Oberoi Hotels
17:18
Shivanshu Agrawal
Рет қаралды 1,5 МЛН
Saudi Arabia’s giant money pit: NEOM | If You’re Listening
13:28
ABC News In-depth
Рет қаралды 544 М.
Kolkata Doctor Case
32:57
Nitish Rajput
Рет қаралды 12 МЛН
LeetCode was HARD until I Learned these 15 Patterns
13:00
Ashish Pratap Singh
Рет қаралды 321 М.
From ₹10/day to ₹1.4 Lakhs Passive Income?
16:25
Wint Wealth
Рет қаралды 676 М.
Lecture 5: Bitwise Operators, For Loops, Operator Precedence & Variable Scoping
1:15:44
An Unknown Ending💪
00:49
ISSEI / いっせい
Рет қаралды 49 МЛН