Find the Difference - Leetcode 389 - Python

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

NeetCodeIO

Жыл бұрын

🚀 neetcode.io/ - A better way to prepare for Coding Interviews
🥷 Discord: discord.gg/ddjKRXPqtk
🐦 Twitter: neetcode1
🐮 Support the channel: www.patreon.com/NEETcode
⭐ BLIND-75 PLAYLIST: kzbin.info/www/bejne/gX3PiXZ8fJqHpKM
💡 DYNAMIC PROGRAMMING PLAYLIST: kzbin.info/www/bejne/bWTVZH6Nnqqpr80
Problem Link: leetcode.com/problems/find-the-difference/
0:00 - Read the problem
0:30 - Hashmap Explanation
2:23 - Hashmap Code
3:56 - ASCII Explanation
5:43 - ASCII Code
6:48 - Bit Manipulation Explanation
9:58 - Bit Manipulation Code
leetcode 389
#neetcode #leetcode #python

Пікірлер: 20
@gaychin8654
@gaychin8654 Жыл бұрын
Wow, exactly what I needed! Also, for those who don't know, XOR operation is both associative and commutative, therefore, the sequence of characters will not affect the output.
@MP-ny3ep
@MP-ny3ep Жыл бұрын
Thank you for the daily problems ! Love the multiple approaches.
@infinitygod5379
@infinitygod5379 Жыл бұрын
Liked the xor approach
@Banaaani
@Banaaani Жыл бұрын
The last solution is just mind blowing!
@servantofthelord8147
@servantofthelord8147 3 ай бұрын
ikr! I never knew we could do this with bits
@michomapeter941
@michomapeter941 Жыл бұрын
Bro youre the best ,We really appreciate your efforts ,Thankyou
@ymncore
@ymncore Жыл бұрын
thank you so much for solving the daily challenges !!
@houssainebendhieb203
@houssainebendhieb203 Жыл бұрын
Thank you for your efforts it's very helpful
@omaryahia
@omaryahia 3 ай бұрын
how is problem solving going for you? still solving? :)
@jeewan3108
@jeewan3108 Жыл бұрын
XOR approach ❤
@SASA_maxillo
@SASA_maxillo Жыл бұрын
my solution: if s == "": return t for i in s: t = t.replace(i, "", 1) return t i think it is easier and more readable 🙃🙃
@yourAI-Buddy
@yourAI-Buddy Жыл бұрын
The real deal is learning various ways than just for loops and stuff. the XOR method and ascii value calcs are pretty cool
@phpostrich
@phpostrich Жыл бұрын
return chr(sum([ord(ch) for ch in t]) - sum([ord(ch) for ch in s])) # one liner
@phpostrich
@phpostrich Жыл бұрын
return chr(reduce(lambda x, y: x ^ y, [ord(ch) for ch in (t+s)])) # one liner using reduce and XOR 🤔
@downhillskating101
@downhillskating101 Жыл бұрын
same, good one
@anantom251
@anantom251 Жыл бұрын
Did it myself today!! using the hashing. char findTheDifference(string s, string t) { vector mp(27,0); char ans = '0'; // we first initialise the vector array with the freq of the characters of string s; for(auto i=0;i
@rushabhlegion2560
@rushabhlegion2560 Жыл бұрын
I wrote like this class Solution { public: char findTheDifference(string s, string t) { vectorvecS(26,0); vectorvecT(26,0); for(int i=0;i
@jessanraj9086
@jessanraj9086 Жыл бұрын
❤❤
@nikospappas8718
@nikospappas8718 Жыл бұрын
Another one liner return set(t).difference(set(s)).pop()
Part 5. Roblox trend☠️
00:13
Kan Andrey
Рет қаралды 3 МЛН
ДЕНЬ УЧИТЕЛЯ В ШКОЛЕ
01:00
SIDELNIKOVVV
Рет қаралды 4 МЛН
啊?就这么水灵灵的穿上了?
00:18
一航1
Рет қаралды 53 МЛН
小路飞嫁祸姐姐搞破坏 #路飞#海贼王
00:45
路飞与唐舞桐
Рет қаралды 29 МЛН
Part 5. Roblox trend☠️
00:13
Kan Andrey
Рет қаралды 3 МЛН