Dot Product of Two Sparse Vectors || Leetcode 1570 || 1 Follow-up Question Meta Actually Asks

  Рет қаралды 916

Coding with Minmer

Coding with Minmer

Күн бұрын

Пікірлер: 10
@2NormalHuman
@2NormalHuman 26 күн бұрын
Oh wow that's an awesome explanation, thanks for the video!
@LiadMotorin
@LiadMotorin 25 күн бұрын
Thanks !! please continue with the videos
@AhmedHassan-vo5fz
@AhmedHassan-vo5fz 19 күн бұрын
for the follow up can't we just use the smallest map or tuple as the itertor, then use a hasmap to find if the value is in the other array.
@CodingWithMinmer
@CodingWithMinmer 18 күн бұрын
You absolutely can, but Meta generally won't accept a map. In short, they're worried about collisions if the input is massively large (eh, really it's just their general attitude). A pre-allocated array would be more efficient.
@MrApoorvWalls
@MrApoorvWalls 23 күн бұрын
Wouldn’t it be better to keep the array and in the preprocessing step, instead of creating a list of tuples, we store the non zero indices in a set. Then before we perform the dot product, we can do set1 intersection set2 and just perform multiplication on the indices left in the intersection. It solves both the standard case and the follow up.
@CodingWithMinmer
@CodingWithMinmer 21 күн бұрын
I see what you mean. But one concern is the storage space if we keep the whole array: at least in the Leetcode problem, we can be given upwards 100,000 elements for example.
@insofcury
@insofcury 24 күн бұрын
If we are storing index as key and the actual value as value in the map I don't think there would be any collisions related issue.
@CodingWithMinmer
@CodingWithMinmer 24 күн бұрын
"Most hash table designs employ an imperfect hash function. Hash collisions, where the hash function generates the same index for more than one key, therefore typically must be accommodated in some way." - Wikipedia Reference (yikes, URL encoding): en.wikipedia.org/wiki/Hash_table#:~:text=Most%20hash%20table%20designs%20employ%20an%20imperfect%20hash%20function.%20Hash%20collisions%2C%20where%20the%20hash%20function%20generates%20the%20same%20index%20for%20more%20than%20one%20key%2C%20therefore%20typically%20must%20be%20accommodated%20in%20some%20way.
Merge Sorted Array || Leetcode 88 || 1 Variant Question Meta Actually Asks
10:45
DOT PRODUCT OF TWO SPARSE VECTORS - 3 SOLUTIONS EXPLAINED [PYTHON]
31:06
Сестра обхитрила!
00:17
Victoria Portfolio
Рет қаралды 958 М.
It works #beatbox #tiktok
00:34
BeatboxJCOP
Рет қаралды 41 МЛН
coco在求救? #小丑 #天使 #shorts
00:29
好人小丑
Рет қаралды 120 МЛН
one year of studying (it was a mistake)
12:51
Jeffrey Codes
Рет қаралды 257 М.
Python laid waste to my C++!
17:18
Sheafification of G
Рет қаралды 217 М.
I made maps that show time instead of space
10:44
Václav Volhejn
Рет қаралды 1,3 МЛН
Dynamic Programming isn't too hard. You just don't know what it is.
22:31
DecodingIntuition
Рет қаралды 244 М.
Programming with Math | The Lambda Calculus
21:48
Eyesomorphic
Рет қаралды 257 М.
"Clean" Code, Horrible Performance
22:41
Molly Rocket
Рет қаралды 945 М.
Сестра обхитрила!
00:17
Victoria Portfolio
Рет қаралды 958 М.