L6. Single Number II | Bit Manipulation

  Рет қаралды 25,948

take U forward

take U forward

3 ай бұрын

Notes/Codes/Problem links under day 8 of A2Z DSA Course: takeuforward.org/strivers-a2z...
Follow us on our other social media handles: linktr.ee/takeuforward

Пікірлер: 75
@charansaianisetti5436
@charansaianisetti5436 3 ай бұрын
mind blowing explanation, i love how in depth you are teaching the concepts.
@jjjyotijain
@jjjyotijain 3 ай бұрын
amazing explanation, it took me some time to grasp the concepts of buckets but finally I understood every step. 😅😅
@emmanuelosademe981
@emmanuelosademe981 3 ай бұрын
Excellent explanation. Really loved the Bucket method
@SagarKumar-yr4ky
@SagarKumar-yr4ky 3 ай бұрын
Wonderful explanation man. Keep up the good work.
@_The_-_worst_
@_The_-_worst_ 3 ай бұрын
Make playlist or videos for Competitive programming because I have completed your dsa series 😊
@parasjeeprep3206
@parasjeeprep3206 3 ай бұрын
how much time did it took to complete the playlist and how many videos were you watching everyday
@adarshrai1390
@adarshrai1390 2 ай бұрын
Bro there is competative programming sheet also, if you have finished that do a deep dive in stl if c++ or collections if in Java, then do math a lot, remember no tutorial can prep you for competitive programming it is just you and you have to go deep dive in it and eventually you will learn ,from some who is 2000 on Codeforces. Best of luck
@abhisheksanwal1106
@abhisheksanwal1106 21 күн бұрын
Mastering Segment tree, BIT,dp and graph will surely put you cm or master level but surely it's gonna take a lot of time and effort.
@AK-nj1je
@AK-nj1je 17 күн бұрын
@@adarshrai1390 bro how you counter questions from the topic that you didn't covered, does that mean you have to first cover all the dsa topics and then start cp, btw congo bro, i respect your rating!!
@fomoCoder69
@fomoCoder69 3 ай бұрын
Please Update A2Z DSA Course/Sheet for this series, it helps a lot in revision
@Mohit_Q
@Mohit_Q 3 ай бұрын
kyaaa pyaar solution tha bucket wala loving ittttt
@ArkojyotiDeyOfficial
@ArkojyotiDeyOfficial Ай бұрын
WILL THE BUCKET WORK IF THE NO,S ARE NOT IN CLUSTERS
@Zeeshan_251
@Zeeshan_251 Ай бұрын
@@ArkojyotiDeyOfficial Yes, Works for every possible arrangment of the elements.
@prantikde3121
@prantikde3121 3 ай бұрын
The bucket concept was❤
@RK-Sonide4vr
@RK-Sonide4vr 2 ай бұрын
class Solution { public: int singleNumber(vector& nums) { int ans = 0; for(int bitIndex = 0; bitIndex
@user-ok6km9me6x
@user-ok6km9me6x 3 ай бұрын
Thank you bhaiya.
@AkOp-bf9vm
@AkOp-bf9vm 29 күн бұрын
i never imagine that a question can have that many solutions😂😂
@user-tk2vg5jt3l
@user-tk2vg5jt3l 2 ай бұрын
Thank you bhaiya
@UECAshutoshKumar
@UECAshutoshKumar 3 ай бұрын
Thank you sir 😁
@Rahulyadav-sd3oj
@Rahulyadav-sd3oj 3 ай бұрын
Thank sir 🤩🤩
@A_Myth963
@A_Myth963 3 ай бұрын
For 2nd Bucket - will go to twos if it is in ones - I think there will be a correction here that - it will go to twos if not in ones
@vivekgohel9794
@vivekgohel9794 2 ай бұрын
Same Thought Bro
@dayashankarlakhotia4943
@dayashankarlakhotia4943 3 ай бұрын
public int singleNumber (int[]nums){ int ones=0,twos=0; for(int num:nums){ ones=ones^(num&~twos); twos=twos^(num&~ones); } return ones; }
@kale-lb5pr
@kale-lb5pr 3 ай бұрын
i have one question like i was doing dry and run on array [5,5,5,6,4,4,4] after when array element first 4 comes if we take xor with what ones contains so it technically has 6 bcoz it occured ones then when we xor 6^4 it will not remain 6 pls tell me what im doing wrong something is off i cant pinpoint pls help guys!!
@AkOp-bf9vm
@AkOp-bf9vm 29 күн бұрын
this is not wrong the answer will be (6^4)&(~two). ones will change here but if you completely traverse whole array the ones will contain 6
@user-kq2vd9gh3r
@user-kq2vd9gh3r Ай бұрын
For those who not understand bucket concept , forget about bits and try with numbers only to understand concept . we want to check (ones == twos)but we don't want to lose value of ones there for using ( & ~ twos )
@gugulothsrilakshmi8729
@gugulothsrilakshmi8729 Ай бұрын
i didnt understand this concept can you explain
@divyanshbhatt8273
@divyanshbhatt8273 3 ай бұрын
at 26:35 i feel you wrote and spoke correctly but earlier in rules you stated point number two as it will go to twos, if it is in ones! please confirm striver.
@AkOp-bf9vm
@AkOp-bf9vm 29 күн бұрын
both are correct because that line is used to execute the point "num[i] will go to twos if it is in ones" . lets consider the the array be arr={2,2,2,3} step 1: ones=2 and twos=0 step 2: num[i]==2 and ones is also 2 which means we have to delete 2 from ones. now ones==0 if it the first occurrence of 2 then it should be present in ones but it is not (because ones==0) which means it is the second occurrence of 2 which means 2 is now added in twos that why we use the condition that ***it should not be present in ones*** by ~ones.
@user-kl3qv1sc8k
@user-kl3qv1sc8k 13 күн бұрын
Bucket Method😍
@shalupriyamvada5551
@shalupriyamvada5551 3 ай бұрын
Nice explanation. However I am not able to understand the bucket method yet...Does it work only for the sorted array?
@padmaja577
@padmaja577 2 ай бұрын
Ya similar doubt, I think the array should be sorted....
@vardhani3748
@vardhani3748 Ай бұрын
No it works for unsorted array as well
@yash2275
@yash2275 3 ай бұрын
Can any one please tell When I am doing dry run on [1,2,3,2,3,2,3] It is giving random ans and not the desired output then how at hardware level this is giving correct answer the method was nice but why it didn't prove it's correctness in dry run ????
@AkOp-bf9vm
@AkOp-bf9vm 29 күн бұрын
it will give desired output after the complete traversal of array may be you done some error in your calculation #include using namespace std; int main() { vector arr={1,2,3,2,3,2,3}; int ones=0,twos=0; int n=arr.size(); for(int i=0;i
@ShashiKanthvarma-lb6xb
@ShashiKanthvarma-lb6xb 3 ай бұрын
ohh, i love naive solutions
@adarshsingh4398
@adarshsingh4398 Ай бұрын
@debayanbhunia7084
@debayanbhunia7084 3 ай бұрын
can this solution of checking bits work in case of negative numbers as well?
@user-jo2zo9gs3b
@user-jo2zo9gs3b 3 ай бұрын
yes
@AdiCode_Hub
@AdiCode_Hub 10 күн бұрын
Can it be explained in easy way ? plz
@chickukoshti3741
@chickukoshti3741 3 ай бұрын
UNABLE TO UNDERSTAND BUCKET METHOD !
@103_debopriyoghosh_cse_by6
@103_debopriyoghosh_cse_by6 2 ай бұрын
Same vro😢
@anishsingh4021
@anishsingh4021 6 күн бұрын
🔥🔥🔥
@ManishKumar-dk8hl
@ManishKumar-dk8hl 3 ай бұрын
yehi too chahiye tha
@captainyedla
@captainyedla 26 күн бұрын
17:39 that range is wrong. equalto is missing
@modiji8706
@modiji8706 3 ай бұрын
at 7:54 he is more serious then my carrer
@chiragbansod8252
@chiragbansod8252 3 ай бұрын
that's why u are here
@charansaianisetti5436
@charansaianisetti5436 3 ай бұрын
i have gone through the dsa sheet but unable to find the notes, can anyone guide me where the notes exactly is
@modiji8706
@modiji8706 3 ай бұрын
not update yest..
@rijumondal6876
@rijumondal6876 2 ай бұрын
I sometimes wonder why he is in not from IITs, he should have a permanent seat there
@amanverma5912
@amanverma5912 3 ай бұрын
The question and notes links are not available in the dsa sheet. Please update it!!
@AkOp-bf9vm
@AkOp-bf9vm 29 күн бұрын
bro i am also searching for it 🤣🤣
@factsclub4u
@factsclub4u 13 сағат бұрын
@darshbothra007
@darshbothra007 3 ай бұрын
First one to comment! Excited ❤
@utube4026
@utube4026 3 ай бұрын
Congratulations bro🎉🎉🎉
@modiji8706
@modiji8706 3 ай бұрын
kl rashtrapati bhavan aa jana prize lene
@utube4026
@utube4026 3 ай бұрын
@@modiji8706 😂😂😂😂😂😂
@kale-lb5pr
@kale-lb5pr 3 ай бұрын
pls tell me why in system im getting correct result even if the array is unsorted but while im doing dry and run why im just getting some random result which i dont want pls help me unveil tell me the bit manipulation trick which maybe im not able to see through my naked eyes im not able to pinpoint the mistake pls help guys!!
@AkOp-bf9vm
@AkOp-bf9vm 29 күн бұрын
i think we add the number and also delete it if it is duplicate thats why only unique element will remain in ones
@GoluKumar-sb2si
@GoluKumar-sb2si Ай бұрын
at 17:20 if we take this example after sorting [ 1,1,1,2,3,3,3,4,4,4] then according to code it will give 2 and 3 as a ans ,, but ans should be only 2 so how this code is true .Can anyone explain?
@manjeetyadav5830
@manjeetyadav5830 Ай бұрын
loop will not go ahead after finding 2....2 will be returned
@AkOp-bf9vm
@AkOp-bf9vm 29 күн бұрын
no it only return ans==2 for every index we are checking we will use if(arr[i] != arr[i-1]) return arr[n-1]; it will return n-1 index value
@manishakumari1943
@manishakumari1943 2 ай бұрын
Why can't we xor each element to get the element which is occuring once?
@artifice_abhi
@artifice_abhi 2 ай бұрын
as elements are not in even number if we xor 1 1 1 2 then 1^2 will be left at the end
@manishakumari1943
@manishakumari1943 2 ай бұрын
@@artifice_abhi ok ok got it... thank you for the explanation
@ishanmusic677
@ishanmusic677 3 ай бұрын
Sir i guess at 10:45 , you have used 2 for loops , first goes from i to 31 and second goes from j to n , which is i guess wrong because according to this we are counting the bits row wise but we have to count it colum wise so our loop should be like i to n and j to 31, correct me if im wrong
@SriyanGaming
@SriyanGaming Ай бұрын
no, the way in the video is correct. we want to count the number of 1's in each bit position. so we need to iterate through each bit position first, and then each number from the array to count how many 1's there are. hopefully that makes sense
@kale-lb5pr
@kale-lb5pr 3 ай бұрын
pls help me im not getting answer while im doing dry nd run
@AkOp-bf9vm
@AkOp-bf9vm 29 күн бұрын
it will give desired output after the complete traversal of array may be you done some error in your calculation. #include using namespace std; int main() { vector arr={1,2,3,2,3,2,3}; int ones=0,twos=0; int n=arr.size(); for(int i=0;i
@AkOp-bf9vm
@AkOp-bf9vm 29 күн бұрын
suggestion for you:: you can also try to get answer from chatgpt . most of the time it will find error in your code . It will save your lot of time.
@ayushkhairnar7154
@ayushkhairnar7154 3 ай бұрын
kuch samja nahi
@Lucifer_The_Devill
@Lucifer_The_Devill 2 ай бұрын
bhai yr aisi english mt bolo ki smgh hi na aye kuch chota sa concept smjhne me itni mehnt lg gyi
@AkOp-bf9vm
@AkOp-bf9vm 29 күн бұрын
😂😂 ha bhai sach m kabhi kabhi samjh m aana band ho jata h ,,bhai ki english to nxt lvl hai
@kale-lb5pr
@kale-lb5pr 3 ай бұрын
#include using namespace std; int singleNumII(vector a,int n) { int ones=0,twos=0; int i; for(i=0;i
@vardhani3748
@vardhani3748 Ай бұрын
U need to take all elements thrice except one element. If u change 6 to 4.. you'll get the correct output.
L7. Single Number III | Bit Manipulation
24:03
take U forward
Рет қаралды 27 М.
The joker's house has been invaded by a pseudo-human#joker #shorts
00:39
Untitled Joker
Рет қаралды 14 МЛН
1 or 2?🐄
00:12
Kan Andrey
Рет қаралды 27 МЛН
Пробую самое сладкое вещество во Вселенной
00:41
Luck Decides My Future Again 🍀🍀🍀 #katebrush #shorts
00:19
Kate Brush
Рет қаралды 8 МЛН
How I would learn Leetcode if I could start over
18:03
NeetCodeIO
Рет қаралды 282 М.
8 patterns to solve 80% Leetcode problems
7:30
Sahil & Sarra
Рет қаралды 209 М.
5.5 Math Books For Self Made Mathematicians
25:50
The Math Sorcerer
Рет қаралды 26 М.
I Parsed 1 Billion Rows Of Text (It Sucked)
39:23
Theo - t3․gg
Рет қаралды 72 М.
L8. XOR of Numbers in a Given Range | Bit Manipulation
9:38
take U forward
Рет қаралды 20 М.
My Brain after 569 Leetcode Problems
7:50
NeetCode
Рет қаралды 2,4 МЛН
Stockfish vs Torch! The new chess Era begins! - Computer Chess Championship 2024
17:30
The joker's house has been invaded by a pseudo-human#joker #shorts
00:39
Untitled Joker
Рет қаралды 14 МЛН