On-screen text
LeetCode
for beginners!
Hash Maps vs. Arrays!
(save this for later!)
(from a software engineer)
swipe
@that_swe_intern
All content is for educational purposes
Google
Microsoft
amazon
So, you want a $200k+ software job from these guys ^
But you don't know when
to use Hash Maps vs Arrays.
Here's my full 4 year degree
In just 3 slides!
swipe
@that_swe_intern
All content is for educational purposes
1) Key-Value Pairs
Winner: Hash Maps!
HashMaps can instantly lookup
pairs of values in O(1) time!
A common example: HHHH
Storing counts of each letter!
word = "banana"
counts = { (b -> 1),
(a -> 3),
(n -> 2),
}
Good JOB
Simple, right? Let's go on.
swipe
@that_swe_intern
All content is for educational purposes
2) Ordered Data
Winner: Arrays!
Use Arrays when order matters!
Indices will instantly get values.
A common example: $ $
Storing stock prices over time!
prices = [ 2 | 8 | 9 | 4 | 5 ]
↑
prices[0] is the stock price on the 0th day!
GREAT
WORK
Simple, right? Let's go on.
swipe
@that_swe_intern
All content is for educational purposes
3) More examples!
Problem:
Sorting data.
Check if we hold
a certain value.
Traverse using pointers.
Preventing duplicate values.
Insert/delete at ends.
Storing key-value pairs.
@that_swe_intern
All content is for educational purposes
Solution:
Array
Hash Map
Array
Hash Map
Array
Hash Map
Good JOB
swipe
Congrats!
You know when to use Hash Maps vs Arrays!
You're on your way to a job with:
1. Great Pay
2. Work-Life Balance
3. Interesting Problems
Keep it up!
Follow to commit to your
goal of breaking into tech!