Тёмный

Add Two Numbers Without The "+" Sign (Bit Shifting Basics) 

Back To Back SWE
Подписаться 240 тыс.
Просмотров 123 тыс.
50% 1

Free 5-Day Mini-Course: backtobackswe.com
Try Our Full Platform: backtobackswe.com/pricing
📹 Intuitive Video Explanations
🏃 Run Code As You Learn
💾 Save Progress
❓New Unseen Questions
🔎 Get All Solutions
Question: Add two integer values without using the "+" operator.
++++++++++++++++++++++++++++++++++++++++++++++++++
HackerRank: / @hackerrankofficial
Tuschar Roy: / tusharroy2525
GeeksForGeeks: / @geeksforgeeksvideos
Jarvis Johnson: / vsympathyv
Success In Tech: / @successintech

Наука

Опубликовано:

 

22 фев 2019

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 503   
@BackToBackSWE
@BackToBackSWE 5 лет назад
Table of Contents The Problem Introduction 0:00 - 0:51 A Way To Think About Number Bases 0:51 - 3:56 Back To The Problem At Hand 3:56 - 4:16 Let's Add Some Numbers (Decimal, Base 10) 4:16 - 4:59 Let's Add Some Numbers (Binary, Base 2) 4:59 - 7:40 Bit Shifting Operators: The 'AND' -> '&' 7:40 - 9:41 Bit Shifting Operators: The 'XOR' -> '^' 9:41 - 11:36 Bit Shifting Operators: The 'Left Shift' -> '
@danavram8437
@danavram8437 4 года назад
What do you mean? It also works on negative numbers (great explanation of the whole process btw :) ). I used this algorithm on leetcode in C++ (and it has to work with negative numbers as well). The only catch is that I had to convert the carry to unsigned when doing the left bitshift (which wraps the bits around with 1111....11 (32 bits)) int getSum(int a, int b) { while(b) { int carry = a & b; // get all carry bits (all 1&1s) a = a^b; // sum of disjoint bits (everything except what needs to be carried) // shift carry by one, as this is how a regular sum operation works // the carry is moved to the next position b = (unsigned)carry
@BackToBackSWE
@BackToBackSWE 4 года назад
yeah
@arunprakash1101
@arunprakash1101 4 года назад
Hey !! This explanation is excellent! But I can't see the code for this problem in the description! Is it moved?
@willinton06
@willinton06 4 года назад
Arun Prakash same here
@anjalibelani5101
@anjalibelani5101 4 года назад
Thank you for these videos. However, I dont see the code in the description in any of your videos. Am I missing something?
@minhazulislam4682
@minhazulislam4682 3 года назад
dude, you need to come back and teach us. the world needs more people like you, blackpenredpen, the organic chemistry teacher, 3blue1brown, nick white, tech with tim, jenny it and many more.
@albertjtyeh53
@albertjtyeh53 3 года назад
is he working at FAANG now?
@MrACrazyHobo
@MrACrazyHobo 3 года назад
@@albertjtyeh53 Back To Back SWE is at twitter!
@dubey_ji
@dubey_ji 2 года назад
Corey Schafer and Sentdex are great too
@anniewiley1425
@anniewiley1425 3 года назад
Hey man I just wanted to say I think these videos are immensely helpful. The way you explain your thought process on these complex but tiny subjects rashly helps a person change the way they think about code, not to mention learning the lingo of a SWE. Also please don't ever lose the awkward endings and outtakes.
@null5245
@null5245 5 лет назад
u r a good teacher bro! Actually i came here because of your comment in leetcode lol :)
@BackToBackSWE
@BackToBackSWE 5 лет назад
nice
@angelanayiga4060
@angelanayiga4060 4 года назад
@@BackToBackSWE I do agree you should make comments on all leet code questions you've solved! That's how I landed on B2B SWE!
@BackToBackSWE
@BackToBackSWE 4 года назад
@@angelanayiga4060 hey
@harshag5423
@harshag5423 4 года назад
@@angelanayiga4060 Now because of your comment I landed on B2B which I didn't even know.
@angelamukisa4433
@angelamukisa4433 4 года назад
Harsha G I’m really glad you landed on it and I hope it helps you the way it helped me 🤗🙏🏾
@baichen6449
@baichen6449 4 года назад
your explanation really helps people who were totally lost, like me.
@BackToBackSWE
@BackToBackSWE 4 года назад
nah, ur good
@SR-we1vl
@SR-we1vl 4 года назад
Whenever I get stuck on a problem and see if your video is there, I'm relieved! Thank you man!
@BackToBackSWE
@BackToBackSWE 4 года назад
Nice sure
@CodingForRealLife
@CodingForRealLife 5 лет назад
Now I understand a lot of techniques that I wasn't able to understand before by following your channel, keep it up!
@BackToBackSWE
@BackToBackSWE 5 лет назад
nice
@rtothec1234
@rtothec1234 Год назад
I took compsci and learned this but could never explain to my friend who couldn’t grasp it. She struggled the whole time. This is such a great explanation and you are an excellent teacher.
@donurukirankumarreddy8872
@donurukirankumarreddy8872 5 лет назад
The best teaching that I have seen in my life till now is yours .
@BackToBackSWE
@BackToBackSWE 5 лет назад
thanks
@cuteypatootie
@cuteypatootie 2 года назад
I have spent literal years glossing over bitshifting because no explanation could come close to me understanding it. I now have at least a basic knowledge and a starting place. Thank you!
@AlexanderFilippov-ua
@AlexanderFilippov-ua 4 года назад
This is the best explanation I've ever seen! Thanks a lot!!!
@BackToBackSWE
@BackToBackSWE 4 года назад
sure
@vS-xv7vm
@vS-xv7vm 3 года назад
Explanation is so good that we won't need to write code for this in interview - just a dry-run with example would do.
@BackToBackSWE
@BackToBackSWE 3 года назад
ye
@haleygu2171
@haleygu2171 4 года назад
Faced this problem in an interview with Qualcomm ... I wish I could see this video earlier to come up with bit manipulation solution :( Thanks a lot for clear explaination!
@BackToBackSWE
@BackToBackSWE 4 года назад
nice
@prithazz
@prithazz 4 года назад
This is a stupid interview question to ask.. honestly, they don't deserve you.
@snlagr
@snlagr 4 года назад
@@prithazz maybe they wanted to check low level understanding
@musicvoice3030
@musicvoice3030 4 года назад
Genuinely explained. Excellent, keep doing your work. You`re a great teacher.
@BackToBackSWE
@BackToBackSWE 4 года назад
thanks.
@PiBiNi
@PiBiNi 4 года назад
Loved the way you explained even the basics. Thank you.
@BackToBackSWE
@BackToBackSWE 4 года назад
sure
@PheezxCoding
@PheezxCoding 2 года назад
Your explanations are always so clear and engaging.
@hoboshenanigans
@hoboshenanigans 4 года назад
Dude keep it up, i've learned more from you then my attempt at graduate school lol
@BackToBackSWE
@BackToBackSWE 4 года назад
ha nice
@janmichaelaustria620
@janmichaelaustria620 4 года назад
Likewise!
@datle5503
@datle5503 3 года назад
This is the ultimate guide to this hell of bits manipulation. Thank you so much.
@xulinazrx
@xulinazrx 3 года назад
You are awesome! Your presentation is so clear and easy to understand!
@harinijeyaraman8789
@harinijeyaraman8789 4 года назад
This was super helpful !! You're amazing at teaching !
@BackToBackSWE
@BackToBackSWE 4 года назад
thanks - glad it helped
@ShuangyiHu
@ShuangyiHu 5 месяцев назад
You are such a good teacher! Thanks for breaking down the basics and emphasizing the details!
@thev01d85
@thev01d85 3 года назад
You are extremely talented at teaching this stuff, I have struggled with bitwise operations for a while now, however after watching your explanation I was able to implement this myself, which is a major break through. Thank you for this video!
@BackToBackSWE
@BackToBackSWE 3 года назад
Glad to know we could help!
@jkim5118
@jkim5118 5 лет назад
I am always impressed with your videos. How do you choose the questions? It seems like you have a set of question that you plan to cover and I can feel that those questions are more relevant to actual skills that we need for interviews (not like brain teasers). Also, what's your plan after to cover all planned questions?
@BackToBackSWE
@BackToBackSWE 5 лет назад
I built a list of like 300 when I started this channel. But at some point I just started doing the most burning questions that I felt that I just HAD to try to cover. And as for plans after I have many questions covered...eh, I don't know. Here is my rough plan for this project: backtobackswe.com/plans I don't think any human can ever cover all questions. But they can cover all topics and concepts. This channel is far from the latter.
@Cyber99221
@Cyber99221 3 года назад
Oh wow! Cool, this was a nice refresher. Great video
@user-su1pu2bm4y
@user-su1pu2bm4y 2 года назад
My Brother, since college back in 1999, I haven't had to use it. But, you have refreshed my way of thinking. Thanks and continue to progress forward!!!!
@maxxxxx93
@maxxxxx93 5 лет назад
very well explained solution! i think it’s worth noting that this only really works with positive integers
@BackToBackSWE
@BackToBackSWE 5 лет назад
Yeah, true, I'll add that to the notes.
@Mysticbeing21
@Mysticbeing21 Год назад
Ive learnt alot today. Ive been struggling these days and i was almost burn out because of the amount of unfinished projects i had. Thank you
@BackToBackSWE
@BackToBackSWE Год назад
Happy to help
@CHIRANJIBNANDY1
@CHIRANJIBNANDY1 5 лет назад
Bro...u r a genius.... thanks for making me prepared.
@BackToBackSWE
@BackToBackSWE 5 лет назад
nice! good luck
@amanzholdaribay9871
@amanzholdaribay9871 4 года назад
Man, that's been interesting and fun to listen to you! Thanks! I got topic)
@BackToBackSWE
@BackToBackSWE 4 года назад
nice
@ericcoleman2288
@ericcoleman2288 2 года назад
Great video man ✊🏾
@cshivani
@cshivani 4 года назад
Excellent, you have put in lot of effort in explaining it, thanks appreciate it!! :)
@BackToBackSWE
@BackToBackSWE 4 года назад
sure
@ZhenyaVlasov
@ZhenyaVlasov 4 года назад
Thanks for your vids. I found some inconsistencies with your explanation. At 11:48 you say that when we do shift, '1 gets shifted out'. However, it doesn't. As an example, take 0101 (5) and 1101(13) When shifting, we add 0 on the right side and if carry started with 1, it will grow as well. We can't loose the first 1 because just like other 1s in the carry, it specify an index where we need to carry over. In the provided github code, line 134, it says "1 got shifted out". Again, if we shift it, we will loose part of our answer. The reason why, at some point, 'carry' becomes 0 and we brake out of the loop, because on 3rd iteration after increasing the carry by one more digit, we will be performing '&' operation between 4 digit (0010) and 5 digit (10000). The result of it will be 00000. Result of the '^' operation will be 10010 (which, again, won't be possible if we lost that left most '1'. 'carry
@BackToBackSWE
@BackToBackSWE 4 года назад
Woah, a lot to parse, will need to jog my memory on this one. And nice, hey, I'm in Maryland rn so oof
@demigod6190
@demigod6190 3 года назад
Thank you very much. Finally, I got the concept!
@alex-gz7ud
@alex-gz7ud 3 года назад
Thank you for the explanation!! You are awesome!!!
@OhsoLosoo
@OhsoLosoo 2 года назад
Love you man. I'm in Graduate school & your videos have helped me so much.
@hrithikdhanraj2919
@hrithikdhanraj2919 2 года назад
That's simply Great. I appreciate your work. Thanks for the explanation ♥️♥️
@mallikarjunpidaparthi
@mallikarjunpidaparthi 3 года назад
Wow. You made it so simple. Thank you sir.
@sanapalavenkatesh5273
@sanapalavenkatesh5273 3 года назад
Awesome explanation.. By the way once again thank you for ...
@FreeMayaTutorials
@FreeMayaTutorials 4 года назад
Thank you, I'm learning so much from your lectures!
@BackToBackSWE
@BackToBackSWE 4 года назад
great
@jeromepowell1423
@jeromepowell1423 2 года назад
Great video. Speaking the entire process through like the computer solidified it for me.
@Firstusee256
@Firstusee256 5 лет назад
You helped a lot , thank you for making such kind of videos.....
@BackToBackSWE
@BackToBackSWE 5 лет назад
sure
@conniekang6707
@conniekang6707 2 года назад
this is so helpful thank you!
@SpiffyFurFamily
@SpiffyFurFamily 2 года назад
Best explanation I've seen. It helped me implement my C# program! Could you do a similar video for substraction without using arithmetic operators?
@shyammuppidi2092
@shyammuppidi2092 4 года назад
Awesome bro love all your videos
@BackToBackSWE
@BackToBackSWE 4 года назад
thank you.
@girishthatte
@girishthatte 4 года назад
Awesome explanation covering from basics 🔥
@BackToBackSWE
@BackToBackSWE 4 года назад
thx
@Sarah-il5dr
@Sarah-il5dr 4 года назад
You are my go to when comes to all questions!
@BackToBackSWE
@BackToBackSWE 4 года назад
ye
@justin.j4440
@justin.j4440 11 месяцев назад
Nicely explained!
@abhilashpatel3036
@abhilashpatel3036 3 года назад
So clearly explained, i can't thank enough. 👍
@vadimpopov1674
@vadimpopov1674 3 года назад
Amazing explanation, much thanks !
@DangThinh261
@DangThinh261 2 года назад
this is so helpful. Thank you
@khssameernew
@khssameernew 5 лет назад
Excellent explanation, thank you!
@BackToBackSWE
@BackToBackSWE 5 лет назад
sure
@r1jsheth
@r1jsheth 5 лет назад
Man!!! This is so helpful!!!
@BackToBackSWE
@BackToBackSWE 5 лет назад
sure
@asmitadhungana3790
@asmitadhungana3790 2 года назад
This was a real cool and intuitive explanation! Thanks!
@BackToBackSWE
@BackToBackSWE 2 года назад
Thank You, Glad you liked it. Do check out backtobackswe.com/platform/content and please recommend us to your family and friends :)
@SebastianTysler
@SebastianTysler 3 года назад
That is an awesome explanation! Thanks!!!!
@fartzy
@fartzy 2 года назад
Great video man
@namanshah9216
@namanshah9216 4 года назад
What an explanation man! thank you ton!!
@BackToBackSWE
@BackToBackSWE 4 года назад
sure
@blackfeather6230
@blackfeather6230 3 года назад
Explanation is awesome bro
@pradhumansingh3933
@pradhumansingh3933 2 года назад
Thanks a lot.Ur explaination really cleared my doubt....
@shabbirk
@shabbirk 2 года назад
Thank you for the superb explanation!
@ankuragarwal4014
@ankuragarwal4014 4 года назад
Amazing explanation !! Thanks for your effort
@BackToBackSWE
@BackToBackSWE 4 года назад
sure
@reemasharma6188
@reemasharma6188 3 года назад
You did such a great job at explaining this tedious problem. Please make a video on Dynamic programming concepts as well. :-)
@BackToBackSWE
@BackToBackSWE 3 года назад
ok
@cozywanderer
@cozywanderer 3 года назад
This was a fantastic explanation!!
@BackToBackSWE
@BackToBackSWE 3 года назад
thanks
@goofenhour2697
@goofenhour2697 2 года назад
You are amazing! Thank you
@deepjyotkaurbindra
@deepjyotkaurbindra 3 года назад
Amazing explanation!
@finiteimpulse3765
@finiteimpulse3765 4 года назад
A short video like this about Two's complement would be great.
@BackToBackSWE
@BackToBackSWE 4 года назад
ok
@robinsardella5844
@robinsardella5844 4 года назад
Thank you! Helped me alot
@BackToBackSWE
@BackToBackSWE 4 года назад
sure
@prashanthg6174
@prashanthg6174 3 года назад
This video helped a lot, thanks
@fredwooten14
@fredwooten14 5 лет назад
Great videos my brother!
@BackToBackSWE
@BackToBackSWE 5 лет назад
thanks
@raj_kundalia
@raj_kundalia 2 года назад
thanks for the explanation!
@firedragontamer8330
@firedragontamer8330 2 года назад
Very helpful but the code examples are missing from the description, were they removed?
@rachububna509
@rachububna509 2 года назад
Thanks man!
@OhsoLosoo
@OhsoLosoo 2 года назад
Using that ad to cover the redundant statement was brilliant lmao. I would've never noticed it was repeated if you didn't point it out honestly.
@ilshatt
@ilshatt Год назад
Very nice explanation!
@VladimirTheAesthete
@VladimirTheAesthete 2 года назад
That's a pretty intuitive explanation here!
@shrutiagrawal6065
@shrutiagrawal6065 4 года назад
this is really awesome. really loved it gr8 work!!!! all doubts are solved thanks..!!!!
@BackToBackSWE
@BackToBackSWE 4 года назад
sure
@LucianoBargmann
@LucianoBargmann Год назад
It was great. Thanks
@siddhantsharma4011
@siddhantsharma4011 9 месяцев назад
Glad I found this channel. Truly amazing 🎉
@BackToBackSWE
@BackToBackSWE 9 месяцев назад
Happy Halloween 🎃 Thank you for your kind words, Siddhant! Let us know other topics we could cover! We'd love to offer you 50% Off our exclusive lifetime membership use the code SPOOKY50 - backtobackswe.com/checkout?plan=lifetime-legacy&discount_code=SPOOKY50
@sudheer7312
@sudheer7312 5 лет назад
thanks man, it really helped
@BackToBackSWE
@BackToBackSWE 5 лет назад
sure
@femi_alogba
@femi_alogba 2 года назад
Excellent teacher. Excellent!!
@jiangfenglin4359
@jiangfenglin4359 5 лет назад
really helpful!! TY
@BackToBackSWE
@BackToBackSWE 5 лет назад
sure
@traveltechtaste41
@traveltechtaste41 3 года назад
Thanks for explaining this so clearly
@BackToBackSWE
@BackToBackSWE 3 года назад
sure!
@top-list6450
@top-list6450 4 года назад
Thank you so much for the clear explanation. Could you please upload video on Division as well
@BackToBackSWE
@BackToBackSWE 4 года назад
yes
@FabioMontefuscolo
@FabioMontefuscolo 5 лет назад
Awesome! Thank you very much!!
@BackToBackSWE
@BackToBackSWE 5 лет назад
sure
@lets_see_777
@lets_see_777 5 лет назад
best explanation, subbed
@BackToBackSWE
@BackToBackSWE 5 лет назад
thanks
@claushellsing
@claushellsing 2 года назад
You my friend are amazing !! Thanks
@alexeydemyanchuk
@alexeydemyanchuk 2 года назад
Best explanation, so thank you, man!
@vivaanbaid9975
@vivaanbaid9975 2 года назад
love this channel!
@BackToBackSWE
@BackToBackSWE 2 года назад
thanks buddy! try our 5 day free mini course for some awesome content - backtobackswe.com/
@pritomdas6215
@pritomdas6215 4 года назад
wow...it did take me a lot of rewinding to understand, but thanks to God I finally could get the whole picture of how it works.
@BackToBackSWE
@BackToBackSWE 4 года назад
nice
@omkargunjal1611
@omkargunjal1611 4 года назад
Never thought about this logic 😯😯.... Amazing 😍😍
@BackToBackSWE
@BackToBackSWE 4 года назад
sure
@abcdeereijgfhd3215
@abcdeereijgfhd3215 3 года назад
brilliant explanation~!
@humengineerhaijholalekarni8408
@humengineerhaijholalekarni8408 4 года назад
OMG came from Geeksforgeeks. Thank you so much sir.
@BackToBackSWE
@BackToBackSWE 4 года назад
sure
@deepamgoel5396
@deepamgoel5396 4 года назад
Hey, thanks for the video! You're the best. Can you make more videos on bit manipulation please?
@BackToBackSWE
@BackToBackSWE 4 года назад
thx - thx - sure
@youngee9403
@youngee9403 4 года назад
thanks bro these are great i really love ur vids
@BackToBackSWE
@BackToBackSWE 4 года назад
great
@tulufokaki6947
@tulufokaki6947 3 года назад
Thank you so much, this solve my wondering for years as not an engineer
@kevinkkirimii
@kevinkkirimii 3 года назад
I start so well, then I just get lost. I have to find a way to get this concepts in my head permanently.
@AarshSharma
@AarshSharma 4 года назад
Haven't seen a better explanation. Kudos.
@BackToBackSWE
@BackToBackSWE 4 года назад
thanks
@igo1071
@igo1071 4 года назад
U R an excellent teacher 👍🏼thanks a lot ✔️
@BackToBackSWE
@BackToBackSWE 4 года назад
Thanks sure - parents....
@konstantinbrodin3398
@konstantinbrodin3398 5 лет назад
Thank you!
@BackToBackSWE
@BackToBackSWE 5 лет назад
sure
@sapanmore21
@sapanmore21 4 года назад
Awesome explanation!
@BackToBackSWE
@BackToBackSWE 4 года назад
sure
@gabrieldjebbar7098
@gabrieldjebbar7098 5 лет назад
Nice video ! You're a good teacher :)
@BackToBackSWE
@BackToBackSWE 5 лет назад
Thanks
Далее
Sum of Two Integers - Leetcode 371 - Java
11:48
Просмотров 111 тыс.
Qalpoq - O'z eriga qaynona (hajviy ko'rsatuv)
34:31
Просмотров 141 тыс.
Bitwise Operations & Bit Masking
13:08
Просмотров 33 тыс.
Why Europe’s Economy is Doing Better than You Think
8:19
Why "pop-up" restaurants are everywhere now
6:05
Просмотров 529 тыс.
The most beautiful equation in math.
17:04
Просмотров 30 тыс.
Fast Inverse Square Root - A Quake III Algorithm
20:08
The Greenwich Meridian is in the wrong place
25:07
Просмотров 648 тыс.
Samsung vs iPhone ☠️ #shorts
0:18
Просмотров 11 млн
Открываем домофоны с Mi Band 9
0:59
Просмотров 182 тыс.
КАКОЙ SAMSUNG КУПИТЬ В 2024 ГОДУ
14:59