Bitwise Operations tutorial #1 | XOR, Shift, Subsets

Part 1 of tutorial on bitwise operations and bit manipulation in Competitive Programming: bitwise AND, OR, XOR, left and right shift, iterating over all subsets of a set. The content is the same as in my Codeforces article codeforces.com/blog/entry/73490. You can find more advanced tricks in TopCoder bits tutorial www.topcoder.com/community/co....
Subscribe for more educational videos on algorithms, coding interviews and competitive programming.
- Github repository: github.com/Errichto/youtube
- Live streams on 2nd YT channel and on Twitch: / errichto2 & / errichto
- FB and Twitter: / errichto & / errichto
- Frequently Asked Questions: github.com/Errichto/youtube/w...

Пікірлер: 154

  • @bharatkumarshukla3743
    @bharatkumarshukla37434 жыл бұрын

    Erichto please have a series for competitive programming algorithms. It would be really helpful. Nice video.

  • @TheSd321
    @TheSd3214 жыл бұрын

    Thanks for making videos on specific topic. I liked your tutorials on DP and Binary search (On the general way to think where to use this algo.), I would love to see similar videos. Thanks, again!

  • @muhammadhashmi1571
    @muhammadhashmi15714 жыл бұрын

    The best thing about this is, you started from scratch and showed bitwise usage in iterative method. Outclass !

  • @poorgang
    @poorgang4 жыл бұрын

    Omg i really need this. Thank you Erricto ❤️

  • @rashmikiranpandit8962
    @rashmikiranpandit89624 жыл бұрын

    You are so intellingent at the same time so humble and down to earth, thank you for sharing your knowledge. All your videos and blogs are extremely useful.

  • @arkalykakash9475
    @arkalykakash94754 жыл бұрын

    Got here from LC daily challenge video. Man this is GOLD! Thank you so much for sharing this!

  • @TurboWindex
    @TurboWindex Жыл бұрын

    Thank you for taking some of your time to share your knowledge, I'm sure I speak for the whole community when I say it's very appreciated.

  • @ManojKumar-hj7fh
    @ManojKumar-hj7fh4 жыл бұрын

    Hello Errichto Thank you for all the knowledge. Keep making more videos on Data structures and algorithms.

  • @angelmotta
    @angelmotta3 жыл бұрын

    Thanks you so much Errichto!! Excellent explanation and thanks for all your comments to keep it simple to understand! Greetings from Peru!

  • @goni2867
    @goni28674 жыл бұрын

    Thank you very much! I am preparing for the informatics olympiad and I was searching for exactly these things for a long time.

  • @juliap.5610
    @juliap.56103 жыл бұрын

    Thank you so much 🥰🥰 I finally understand how the algorithm to print the binary representation works! You're a such a good teacher

  • @Artificial_Intelligence_AI
    @Artificial_Intelligence_AI4 жыл бұрын

    new subscriber because of how well you explained this!!! I'll start watching all your content and see what I can find :D

  • @sonamsodani3272
    @sonamsodani32722 жыл бұрын

    Thanks! The best explanation for bitwise operations and using bitmasking to solve subset problems.

  • @Ashwanisharma-sf7ri
    @Ashwanisharma-sf7ri4 жыл бұрын

    Thankyou Kamil , detailed videoes on several topics from beginner to high level will be highly appreciated....

  • @anshjain257
    @anshjain2574 жыл бұрын

    Beautifully explained man . Plz add more and more videos on bit manipulation.

  • @tzhou3301
    @tzhou33014 жыл бұрын

    This is great. Looking forward to the next one!

  • @josephwong2832
    @josephwong28324 жыл бұрын

    Thanks for the videos on bit manipulation Errichto!!

  • @vishvish
    @vishvish3 жыл бұрын

    Thanks for this, really helpful video. I found the ending on subsets slightly confusing, and did not understand it, but everything else was great!

  • @d.d898
    @d.d8984 жыл бұрын

    your videos are the best one competitive programmer can as for!!!!

  • @shreyashvardhan5777
    @shreyashvardhan57774 жыл бұрын

    your tutorials are awesome !! please make more of them .

  • @radian1243
    @radian12434 жыл бұрын

    Great video as always, but nothing beats listening to your geometry lecture in person at the POI training camp :D

  • @happyhappyguy5034

    @happyhappyguy5034

    4 жыл бұрын

    @Hetan Thakkar sorry no

  • @radian1243

    @radian1243

    4 жыл бұрын

    @Hetan Thakkar no, it wasn't filmed, just listened to as a way of preparation for the POI

  • @antonykelvin6645
    @antonykelvin66454 жыл бұрын

    Great Video! Waiting for the next lecture :D

  • @raselhasan2433
    @raselhasan24334 жыл бұрын

    Thanks for this tutorial, as I am a beginner it helped me a lot, Waiting for your best lectures/

  • @fbru02
    @fbru024 жыл бұрын

    Can't wait for next one!

  • @faridgadzhiev1440
    @faridgadzhiev14404 жыл бұрын

    Thank you, Errichto, very much appreciated!

  • @PoCTu85
    @PoCTu854 жыл бұрын

    This was very informative. Good job!

  • @user-wj9nn2we1o
    @user-wj9nn2we1o3 жыл бұрын

    x % 2 is not exactly the same as x & 1. For non-negative number it is but if your number is negative x % 2 will give you a negative result. For example -5 % 2 = -1 and -5 & 1 = 1. Keep that in mind when you are dealing with negative numbers.

  • @wannabe945
    @wannabe9454 жыл бұрын

    Thanks, man. Waiting for the next part. :)

  • @suryanshgoel7062
    @suryanshgoel70623 жыл бұрын

    Great Work Sir...Really Appreciate your work...Please keep on uploading.

  • @bhavana6544
    @bhavana65443 жыл бұрын

    Sir...thank you very very much for the great help that you have provided through these videos . I feel very sad that I couldn't get to these videos earlier. Anyway . I love your videos n pattern of teaching . Thanks again a lot❤️

  • @jimmorrisshen
    @jimmorrisshen4 жыл бұрын

    Thanks for your posting. It is excellent as always.

  • @martjao
    @martjao4 жыл бұрын

    Awesome video!, I would like to see more videos about DP :D

  • @shreyasingh542
    @shreyasingh5423 жыл бұрын

    Isn't he lovely? Great explanation straight to the point unlike others💛

  • @krishshah3974
    @krishshah39743 жыл бұрын

    This was so nicely explained! Thank you so much. :)

  • @chengjinfei8139
    @chengjinfei81392 жыл бұрын

    This is the best tutorial for bitwise operation.

  • @nassimnedjar2063
    @nassimnedjar20634 жыл бұрын

    a good tutorial , good job Errichto

  • @gurisingh91298
    @gurisingh912982 жыл бұрын

    Sir please have a complete course/series for competitive programming(including data structures and with practice questions) . It would be really helpful.

  • @1moreredcoder
    @1moreredcoder Жыл бұрын

    lotes of love sir please upload all algorithm 💥💥

  • @jaybabaofficial
    @jaybabaofficial3 жыл бұрын

    Very very thank you sir for this video I just subscribed your channel after seeing this video

  • @suryaakella4508
    @suryaakella45084 жыл бұрын

    badly needed this video thanks a lot

  • @ask4144
    @ask41444 жыл бұрын

    thank you Errichto! where could I find exercises like the last one?

  • @UnfunnyXavier
    @UnfunnyXavier4 жыл бұрын

    *I* *like* *his* *accent*

  • @Errichto

    @Errichto

    4 жыл бұрын

    Well... thanks, I guess :D

  • @danialbagdatuly5618
    @danialbagdatuly56184 жыл бұрын

    We need 2 part Erricto)!

  • @a.syndeed
    @a.syndeed3 жыл бұрын

    I needed an entire hour to understand the code, but now I feel like I have the power of god (exactly what a stupid person usually thinks about themself). Thank you Errichto.

  • @wesammustafa9004
    @wesammustafa90043 жыл бұрын

    Amazing explanation, thank you so much

  • @codecaine
    @codecaine Жыл бұрын

    Excellent examples

  • @giant3dorangutanmodel89
    @giant3dorangutanmodel893 жыл бұрын

    This was extremely helpful, thank you

  • @prantasaha7426
    @prantasaha74264 жыл бұрын

    I found many tricky problems with XOR in different contests. A lot can be done on this topic. So if you make a separate video on the tactics and ingenuity of XOR, we would benefit.

  • @Tarunkumar_Gatla

    @Tarunkumar_Gatla

    3 жыл бұрын

    Can u share Link of those problems

  • @rafayeathossain8731
    @rafayeathossain87314 жыл бұрын

    nice work,love it

  • @ShivamSingh-vu8vq
    @ShivamSingh-vu8vq4 жыл бұрын

    Thanks , I was looking for this

  • @fuadalhasan1784
    @fuadalhasan17844 жыл бұрын

    Wow,... Really nice video.. I Need this kind of video❤

  • @bishnuprasadnayak9520
    @bishnuprasadnayak95204 жыл бұрын

    well you said there is a recursive version of sum of subsets, but first of all i'm not able to come up with a recurrence relation of just finding all the subsets of a given set, i know it's done using recursion and backtracking but just for the mathematical intuition if you can provide with that recurrence relation???

  • @Setofhornsandahalo
    @Setofhornsandahalo4 жыл бұрын

    Hey, thanks for the tutorial. What is the point of doing the for loop on 7:02. Are you looking for the similar x values in the 0...30?

  • @ayushkumar-wt2wm
    @ayushkumar-wt2wm3 жыл бұрын

    Big fan sir...Very nice explanation

  • @jazzhippie3878
    @jazzhippie38783 жыл бұрын

    Errichto!!!! The Khabib of programming!

  • @bikideka7880
    @bikideka78803 жыл бұрын

    I found your binary to decimal converter technique very interesting 3:20

  • @naturalblisshealers5576
    @naturalblisshealers55763 жыл бұрын

    Nice explanation

  • @shivamanand8998
    @shivamanand89984 жыл бұрын

    Very well explained Thank You

  • @kevinje3971
    @kevinje39713 жыл бұрын

    thanks, would you recommend books about this topics particularly?

  • @lepord833
    @lepord8334 жыл бұрын

    Thankyou so much , It's really helpful

  • @acenitd9198
    @acenitd91984 жыл бұрын

    What is the time complexity of the algorithm used ?

  • @ShubhamPandey-un2sy
    @ShubhamPandey-un2sy3 жыл бұрын

    what does n denote here? Number of bits which are to be used or number of elements in the array for which subset problem is to be solved.

  • @mechashadowx
    @mechashadowx4 жыл бұрын

    OMG, that was amazing.

  • @Exzone
    @Exzone4 жыл бұрын

    Amazing video! Amazing explanation. Maybe you could do a video on bitwise interesting problems, like, in an array where elements repeat find one that doesnt repeat etc. I enjoy watching your videos

  • @Zzznmop

    @Zzznmop

    4 жыл бұрын

    Exzone check out Errichto2 channel live-streams, he covers the whole leetcode “interview prep” series in one, which contains many similar problem types to the one you mention

  • @RahulPal-mz4oj

    @RahulPal-mz4oj

    4 жыл бұрын

    @@Zzznmop Can u please provide the link to that video where he explains interview prep questions

  • @mani_naik
    @mani_naik4 жыл бұрын

    Eager for the bitsets video

  • @jean-michelcid9594
    @jean-michelcid95944 жыл бұрын

    last algo was amazing.

  • @jameysiddiqui6910
    @jameysiddiqui69103 жыл бұрын

    in in 32 bit integer if MSB is 1 and left shift is done MSB is lost same as if right shift is done and LSB is 1

  • @Garentei
    @Garentei4 жыл бұрын

    Would love to see some bitmask dp later on too :D thanks

  • @rajarshibose5122
    @rajarshibose51224 жыл бұрын

    Thank you so much, eagerly waiting for part 2

  • @chillerop5110
    @chillerop5110 Жыл бұрын

    I didn't get how we calcuate the subset values using that loop

  • @pratyakshabais7599
    @pratyakshabais7599 Жыл бұрын

    suggestion : plz put playlist link as well in the description

  • @gmmkeshav
    @gmmkeshav4 жыл бұрын

    sir is bitwise shift valid for negative value

  • @nikhillondhe5815
    @nikhillondhe58154 жыл бұрын

    Yes! Much needed

  • @sayedulabrar2574
    @sayedulabrar25744 жыл бұрын

    sir can u please explain what do you mean by a[i]?

  • @ZERINSHAIMAMEEM
    @ZERINSHAIMAMEEM4 жыл бұрын

    Thanks a lot Errichto!!

  • @Digimonfusion280
    @Digimonfusion2803 жыл бұрын

    Where do you learn this? I am making computer science and have never even heard of bitwise operations

  • @shreerammohanty1551
    @shreerammohanty15514 жыл бұрын

    Can you please suggest the software which you use to create these kind of videos???? Like your own video + the writing thing at one page???

  • @lovleshbhatt7797
    @lovleshbhatt77974 жыл бұрын

    Erichto brother u r writing without seeing down to screen , howzzz u do that buddy... Awesome guidance and teaching from erichto..

  • @rohanthube2920
    @rohanthube29204 жыл бұрын

    Very helpful🤟

  • @BedoEbied
    @BedoEbied4 жыл бұрын

    Is it possible to get familiar with this??

  • @ishanshah3309
    @ishanshah33093 жыл бұрын

    Programming Legend!

  • @Rahul-ys3yh
    @Rahul-ys3yh4 жыл бұрын

    This video is treasure!

  • @user-bu8mg7uq3s
    @user-bu8mg7uq3s3 жыл бұрын

    thank you so much

  • @fahimashab1559
    @fahimashab15593 жыл бұрын

    Just Awesome!!!

  • @mandeepubhi4744
    @mandeepubhi47444 жыл бұрын

    Could you do videos on recursion?

  • @rishabhgupta7976
    @rishabhgupta79764 жыл бұрын

    can you make videos on segmented trees implementation it will be very helpfull!!

  • @vudo1013
    @vudo101311 күн бұрын

    thank u so much❤

  • @diegonayalazo
    @diegonayalazo2 жыл бұрын

    Thanks!

  • @rajg7592
    @rajg75923 жыл бұрын

    niesamowity!!!!

  • @sharadVlogs01
    @sharadVlogs014 жыл бұрын

    valuable video

  • @Jayanthsattineni
    @Jayanthsattineni4 жыл бұрын

    I have a doubt... Is predefined stl library functions such as sum or sort are better or manual algo is better for completive programming?

  • @adarshverma013

    @adarshverma013

    4 жыл бұрын

    use stl that will save your time and will be more efficient than your written algo

  • @freindimania11
    @freindimania114 жыл бұрын

    Can someone help me understand this. He says : 10:35 In the first for loop 'n' is the size of number - lets say 32(bits). 10:45 In the second for loop n is the number of elements in the set set 0

  • @wannabe945

    @wannabe945

    4 жыл бұрын

    n is the array/list size here.

  • @manilalgorai7404
    @manilalgorai74044 жыл бұрын

    Thank you.

  • @75395146100
    @753951461004 жыл бұрын

    How do you decide that this problem can be solved using bit operation..I know for basic like if we see xor ya or in question we try to use bitwise but how to get intuition for other questions where we don't see any pattern of using bits??

  • @Errichto

    @Errichto

    4 жыл бұрын

    Just like for any technique: solve a few problems in this topic and then you will start recognizing patterns. Things related to sets and intersections are often solved with bitmasks/bitsets.

  • @suhailakhtar1707
    @suhailakhtar17074 жыл бұрын

    You are the best.

  • @weaponkid1121
    @weaponkid11212 жыл бұрын

    I'm having trouble grasping how this problem indicates bitwise operations should be used. it doesn't seem like a bitwise type of problem

  • @avatarek199
    @avatarek1994 жыл бұрын

    Got one question what is a[i], ok I know its the i-th element, though where is a defined ?

  • @shivambansal1250

    @shivambansal1250

    3 жыл бұрын

    Exactly what i was searching for?

  • @Danny-007

    @Danny-007

    3 жыл бұрын

    I think we assume a as array of n elements....

  • @thetrainoflife8327
    @thetrainoflife83273 жыл бұрын

    you are great

  • @aloneemon9596
    @aloneemon95964 жыл бұрын

    Thank U sir...

  • @Mike-mw1fu
    @Mike-mw1fu4 жыл бұрын

    How should I handle negative number with bitwsie Operation, Errichto?

  • @Errichto

    @Errichto

    4 жыл бұрын

    What do you want to do with negative values? They are represented in binary system in computer so it's possible to compute their bitwise XOR, etc., but what do you want to achieve this way?

  • @Mike-mw1fu

    @Mike-mw1fu

    4 жыл бұрын

    I really need this video. Thanks a billion