Add Binary - Leetcode 67 - Bit Manipulation (Python)

  Рет қаралды 10,131

Greg Hogg

Greg Hogg

Күн бұрын

Пікірлер: 24
@GregHogg
@GregHogg 5 ай бұрын
Master Data Structures & Algorithms for FREE at AlgoMap.io/
@danh9002
@danh9002 Ай бұрын
Great video! For those of us who used to do assembler, it was a nice trip down memory lane!
@tinayu3505
@tinayu3505 2 ай бұрын
how the ampersand left shift trick works is & finds where there is 1 and 1 (the only case that results in carry) and places a 1 to mark the carry, the leftshift applies the carry to the next bit
@ghfranklin
@ghfranklin 4 ай бұрын
Hi sir, from Nigeria, really enjoy watching your videos, wanted to make a request for LRU cache
@anantakesharipanda4085
@anantakesharipanda4085 9 күн бұрын
Could you give a shot to Leetcode *#1073**,* adding negative Binary numbers?
@Ellenki_007
@Ellenki_007 2 ай бұрын
On which editor you are explaining sir?
@user-jm6gp2qc8x
@user-jm6gp2qc8x 4 ай бұрын
Hey gregg! It's time you update the list with some hard level problems or maybe create a new tab and put some hards in them :)
@manikmukhija
@manikmukhija 5 ай бұрын
What language do you think is better for dsa... python or java for future?
@binirxn
@binirxn 5 ай бұрын
C++
@3lpme
@3lpme 4 ай бұрын
Java
@mehrankhan6412
@mehrankhan6412 4 ай бұрын
Hey Gregg I wanted To ask you for a favour Please make A Video On timeseries Dataset Multivariate with Implementation of PCA-LSTM hybrid approach On It
@azimjonalijonov1915
@azimjonalijonov1915 4 ай бұрын
hI CAN YOU GIVE TIPS HOW TO MASTER ATBACKTRACKIGN PROBLEMS?
@shaneastone
@shaneastone 2 ай бұрын
The solution is invalid. String b can be very large and exceed the capacity of an integer.
@xingyuxiang1637
@xingyuxiang1637 2 ай бұрын
I guess the point is to walk through the code and realize that the greedy part is to get all the carriers in one operation. Somehow, the final result matches the correct result. It is hard to prove it wrong mathematically or find a counter-example. A greedy approach, for example, replacing a queue with a priority queue appears in hard problems. I think that the good side in this context is to introduce multi-threading, like multiple threads can get the targets all at once. People usually will not do bit-manipulations a lot. So, that part is exercised. I actually would prefer to see the codes that perform additions concurrently because it aligns with maths. 10^4 does not require greedy approaches most of the time. Clearly, the idea of a greedy approach is harder than DP. Straightforwardly, DP is to list all possible cases by trees, just like a nested for loop, which is actually not needed in the first problem.
@ramziddinaliqulov-zg3jt
@ramziddinaliqulov-zg3jt Ай бұрын
Hello my name is Otabek. I am from Uzbekistan. I am 15 years old.I am going to be member of IOI. But I don't understand DSA.Please help me ?
@alchenerd
@alchenerd Ай бұрын
What the... How do you deal with overflow of the variable `carry`? ``` cpp[] string addBinary(string a, string b) { if (a.size() < b.size()) { return addBinary(b, a); } reverse(a.begin(), a.end()); reverse(b.begin(), b.end()); bool carry = false; string s = ""; for (int i = 0; i < a.size(); ++i) { bool aa = a[i] == '1'; bool bb = i < b.size() ? b[i] == '1' : false; char digit = '0' + (aa ^ bb ^ carry); s += digit; carry = (carry & (aa | bb)) | (aa & bb); } if (carry) { s += '1'; } reverse(s.begin(), s.end()); return s; } ```
@anantakesharipanda4085
@anantakesharipanda4085 9 күн бұрын
That’s the beauty of python, int do not overflow, python just dynamically allocates more bits to store a larger int. Similar to what you’d see in Boost libraries of C++.
@ramziddinaliqulov-zg3jt
@ramziddinaliqulov-zg3jt Ай бұрын
Give me roadmap please ?!
@shhhrruutii
@shhhrruutii 3 ай бұрын
Hey thank you. Can you upload more videos on DSA with python. It's really helping me since I'm currently a computer science engineering student and on my way to become a data scientist.
@user-jm6gp2qc8x
@user-jm6gp2qc8x 4 ай бұрын
what the
@akhilmohnn
@akhilmohnn Ай бұрын
Can't we just simply do: final=bin(int(a,2)+int(b,2))[2:] return final
@Rupok08
@Rupok08 5 ай бұрын
sir, i am from bangladesh . i am only 16 years old. i have learned c and learning c++.i dream to work in fang companny .what would be my roadmap ? i kindda suck at solving problem but i try. please help me , you are my insperation 😊😊
@GregHogg
@GregHogg 5 ай бұрын
algomap.io
Single Number - Leetcode 136 - Bit Manipulation (Python)
3:40
Гениальное изобретение из обычного стаканчика!
00:31
Лютая физика | Олимпиадная физика
Рет қаралды 4,8 МЛН
小丑女COCO的审判。#天使 #小丑 #超人不会飞
00:53
超人不会飞
Рет қаралды 16 МЛН
It works #beatbox #tiktok
00:34
BeatboxJCOP
Рет қаралды 41 МЛН
Diameter of Binary Tree - Leetcode 543 - Trees (Python)
11:16
Greg Hogg
Рет қаралды 10 М.
LeetCode 67. Add Binary Solution Explained - Java
10:24
Nick White
Рет қаралды 49 М.
Reverse Bits - Binary - Leetcode 190 - Python
10:13
NeetCode
Рет қаралды 136 М.
LeetCode was HARD until I Learned these 15 Patterns
13:00
Ashish Pratap Singh
Рет қаралды 762 М.
Why is everyone LYING?
7:56
NeetCodeIO
Рет қаралды 383 М.
Add Binary - Leetcode 67 - Python
8:01
NeetCode
Рет қаралды 68 М.
20 Programming Projects That Will Make You A God At Coding
14:27
The Coding Sloth
Рет қаралды 1,6 МЛН
Computer Science Is Not Software Engineering
14:55
Aman Manazir
Рет қаралды 148 М.
Гениальное изобретение из обычного стаканчика!
00:31
Лютая физика | Олимпиадная физика
Рет қаралды 4,8 МЛН