Тёмный

Daily Dose of LeetCode: Two Sum 

The Coding Sloth
Подписаться 157 тыс.
Просмотров 6 тыс.
50% 1

Hello everyone, this is YOUR Daily Dose of LeetCode (Definitely didn't copy ‪@DailyDoseOfInternet‬ )
In this video, we're tackling the popular Two Sum problem. We'll not only discuss the key takeaways but also delve into understanding the best possible runtime, and explore both brute force and optimized solutions.
Mastering problems like Two Sum is a critical step in your journey as a software developer and in acing that coding interview.
Remember to like, comment, and subscribe to keep up with our LeetCode problem-solving guides, and let me know in the comments if you have any other problems you'd like me to cover.
(Had to reupload since there was a mistake in the brute force solution, whoops)
// TIMESTAMPS //
00:00 - Intro
00:19 - What are the key takeaways?
00:43 - What's the best runtime that we can do?
01:00 - Brute Force Solution
01:35 - Optimized Solution
// SOCIALS //
Twitter: / thecodingsloth1
TikTok: / thecodingsloth
#leetcode #twosum #python #codinginterview #algorithm #programming #coding #pythonprogramming #codingtutorials #computerscience

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

 

16 июн 2024

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 25   
@amrrahmy123
@amrrahmy123 9 месяцев назад
the funny thing is, two loops is actually faster, because checking and adding to a hashmap is an expensive step. So even if it only took one loop, you are doing a lot more work and taking more space in memory in each iteration which demonstrates that O notation is a flawed way of evaluating solutions.
@zalanborbely9177
@zalanborbely9177 12 дней назад
is that true for c++ as well?
@amrrahmy123
@amrrahmy123 11 дней назад
@@zalanborbely9177 yes, you are at least doubling the memory usage, creating a runtime map and adding an additional check. you might think you only looped once, but in each iteration you are going through the hashmap that's already there, adding to it in the loop as well. saying 1 loop is better than 2 loops doesn't take into account that one of them is an fat or expensive loop while the other is a slim loop.
@zalanborbely9177
@zalanborbely9177 11 дней назад
@@amrrahmy123 thats really interesting, but in interviews they still want you to do the hash map solution i assume
@vyy00bet
@vyy00bet 10 месяцев назад
I loved this format of video. Keep it up man
@ashishkushwaha2910
@ashishkushwaha2910 10 месяцев назад
like that you are at top of my search and its grate for you as a starter on you tube. I also liked your style of video can you tell me what and how you do that. like those subtitle and sketches.
@TheCodingSloth
@TheCodingSloth 10 месяцев назад
Thanks! I'm using Adobe Premiere for all my editing, subtitles, and sketches
@official_mosfet
@official_mosfet 9 месяцев назад
Why you have just 539 subscribers? Underrated, for no reason.
@darkPassengerDB
@darkPassengerDB 7 месяцев назад
woah he blew up in a month, 16.2k rn
@rajkishan3690
@rajkishan3690 2 месяца назад
Right now - 87.1k
@billy8461
@billy8461 10 месяцев назад
they assigned me this problem during my interview but I had to find all pairs and not include dups
@Trizzi2931
@Trizzi2931 9 месяцев назад
Seems easy just keep a hast table that is pair to bool which keeps track of if the pair is part of answer or not. Did you solve it?
@billy8461
@billy8461 9 месяцев назад
@@Trizzi2931 yeah and gott the job :)
@Lofisasddle
@Lofisasddle 10 месяцев назад
keep it up bro see if you can use c++
@TheCodingSloth
@TheCodingSloth 10 месяцев назад
Thanks bro, I'll try to add multiple languages in other videos, currently thinking of Python, C++, and Java
@aliaryan786110
@aliaryan786110 8 месяцев назад
Bro is there a good resource for DSA in python. Most resources are in c++/java. Stuck between learning DSA first in C++ then thinking to switch to python. But it's all time consuming.
@andiuptown1711
@andiuptown1711 5 месяцев назад
Neetcode
@Snollygoster-
@Snollygoster- 9 месяцев назад
the space complexity can be eliminated if you just use 2 pointers. while (arr[a] + arr[b] != target) if arr[a] + arr[b} > target; b b-- else a++; That being said though, space complex solutions are usually prettier. Basically every recursive function always has a o(n) space complexity and it sucks because they're so beautifully simple.
@tianchengteh1695
@tianchengteh1695 8 месяцев назад
That assumes that the list is sorted, which it might not be.
@Snollygoster-
@Snollygoster- 8 месяцев назад
@@tianchengteh1695 That's fair, any of the actual test cases would have rekt that strategy (now that I've actually looked)
@tianchengteh1695
@tianchengteh1695 8 месяцев назад
@@Snollygoster- yeah lol
@brunofeitosafl
@brunofeitosafl 9 месяцев назад
had to watch it in 0.5X haha
@Arthur_Heerdt
@Arthur_Heerdt 13 дней назад
i'm cooked
@fab8187
@fab8187 9 месяцев назад
Bruh Can do better we can have O(N) Time and no space comlexity use 2 pointers
Далее
Learn To Code Like a GENIUS and Not Waste Time
9:41
Просмотров 1,2 млн
Daily Dose of LeetCode: Reverse Linked List
8:41
Просмотров 2,5 тыс.
Нюша на премии МУЗ-ТВ 2024 #нюша
00:11
Stone Game II - Leetcode 1140 - Python
18:40
Просмотров 11 тыс.
How principled coders outperform the competition
11:11
Why You Should Learn To Program The Hard Way
15:42
Просмотров 244 тыс.
CSS Tutorial for Beginners
30:28
Просмотров 9 тыс.
How to Solve ANY LeetCode Problem (Step-by-Step)
12:37