SOLVING ALL Arrays & Hashmap | Blind75 LeetCode Problems

preview_player
Показать описание
Today I solve and explain all 8 Blind75 Arrays & Hashing problems live in one sitting.

If you found this helpful Like and Subscribe! I solve LeetCode Algorithms (Python/ Java) and SQL Problems daily!

#leetcode #python #python3 #tutorial #coding #programming
Рекомендации по теме
Комментарии
Автор

How is your LeetCode grind going? Comment below a Leetcode question you need help with!! 🙏

codewithcarter
Автор

Watching people doing these problems differently is really helpful to learn tricks to think and write code efficiently. Thanks for doing this Carter

beanwillis
Автор

🎯 Key Takeaways for quick navigation:

00:00 📚 *Introduction to problem-solving approach*
- Explanation of the Blind75 LeetCode Problems list created by Fang Engineers.
- Overview of the first problem "Contains Duplicates" and the use of a set to detect duplicates efficiently.
02:56 🔄 *Problem-solving approach for "Contains Duplicates"*
- Iterating through the array to check for duplicates.
- Using a set for quick lookup.
- Returning true if a duplicate is found, false otherwise.
05:52 🔄 *Problem-solving approach for "Valid Anagrams"*
- Using a hash map (counter) for letter occurrences.
- Checking if both strings have the same letter occurrences.
- Returning true if anagrams, false otherwise.
08:36 🔄 *Problem-solving approach for "Two Sums"*
- Utilizing a hash map for quick value-index lookup.
- Finding pairs of numbers that sum to the target.
11:31 🔄 *Problem-solving approach for "Group Anagrams"*
- Sorting letters to create a hash function.
- Using a defaultdict to group anagrams.
- Returning the grouped anagrams.
14:59 📊 *Problem-solving approach for "Top K Frequent Elements"*
- Counting occurrences and grouping numbers.
- Using a Max Heap to efficiently retrieve top K elements.
18:00 📊 *Problem-solving approach continued for "Top K Frequent Elements"*
- Using a Max Heap to efficiently retrieve top K elements.
- Iterating through occurrences and updating the result.
19:49 🔄 *Problem-solving approach for "Product of Array Except Self"*
- Handling cases with multiple zeros.
- Calculating the product with and without zeros.
23:51 🔄 *Problem-solving approach continued for "Product of Array Except Self"*
- Calculating the product with and without zeros.
- Constructing the final result array.
25:20 🧩 *Problem-solving approach for "Encode and Decode Strings"*
- Implementing encode and decode methods for a list of strings.
- Concatenating strings with special delimiters for encoding and decoding.
25:34 🧩 *Strings and Delimiters*
- Explains the challenge of converting a list of strings to a single string and back without a clear delimiter.
- Describes a practical solution by specifying the length of the string and using a hash to indicate the delimiter.
- Demonstrates encoding and decoding using the specified approach.
33:10 📈 *Longest Consecutive Sequence*
- Discusses the problem of finding the longest consecutive sequence in an array.
- Proposes an algorithm with O(n) time complexity, avoidingsorting, and using space complexity for optimization.
- Details the approach of iterating through the array, adding numbers to a set, and checking consecutive lengths while avoiding repeated work.

Made with HARPA AI

bharanidharansundar
Автор

Great Video,
Also, want to say that in problem "238. Product of Array Except Self" you used a division operator, but in the problem description is said: "You must write an algorithm that runs in O(n) time and without using the division operation."

alison-in
Автор

I just want to salute your for solving these problems yourself without looking to their solutions or making use of LLMs.

I know this because for some of these problems you didn't give the most efficient solution, which is completely fine given the limited amount of time.

omarllama
Автор

FYI - the code used is not directed towards the most efficient time and space complexity, it's more so to understand the data structures in Python and the methods/functions applied on top of it. If you really want the time space complexity, refer to the original NeetCode videos. Thank you Carter, the videos are a good way of refresher for DE interviews

SAURABHKUMAR-ukgg
Автор

for 242. Valid Anagram if we are allowed to use Counter, why not just ` return Counter(s)==Counter(t)'

mohammad-javadd.b.
Автор

in Q no 2, you can easily sort them, and compare them to check if they are anagrams or not

messiisthebest
Автор

Thank you for the video. Could you do 953. Verifying an Alien Dictionary? I couldn't come up with a solution, and I am lost :(

thegreatestcomesfromthewor
Автор

Hey, what extension are you using to draw on top of your scree?

armandotaveras
Автор

for goptKFrequent, i did something like this ....
def topKFrequent(nums: List[int], k: int) -> List[int]:
hmap = {}
for num in nums:
hmap[num] = 1 + hmap.get(num, 0)
sorted_hmap = dict(sorted(hmap.items(), key=lambda x: x[1], reverse=True)[:k])
return sorted_hmap.keys()
What is the benefit of doing it using heapify - I've never come across that before

cherylto
join shbcf.ru