Search A 2D Sorted Matrix - Fundamentals of Search Space Reduction

preview_player
Показать описание
📹 Intuitive Video Explanations
🏃 Run Code As You Learn
💾 Save Progress
❓New Unseen Questions
🔎 Get All Solutions

Question: There are 2 versions.

Version 1: Every row is sorted left to right in non-decreasing order. The first integer of each row is greater or equal to the last integer of the previous row.

Version 2: Every row is sorted left to right in non-decreasing order. Every column is sorted top to bottom in non-decreasing order. There are no guarantees that the first item of any row or column relates to the last item in the previous row or column.

Sorted. Binary search is very likely. Investigate, how do we reduce our decision space?

Our first answer does not need to be logarithmic (it is so crucial you understand logarithms and what they mean....you need to know your complexities to refine answers and notice avenues to better solutions).

The key to search problems is that you notice the fundamental decision we can make to reduce the problem.

...more notes I wrote...

++++++++++++++++++++++++++++++++++++++++++++++++++

Рекомендации по теме
Комментарии
Автор

Table of Contents:

The Problem Introduction (Variant 1) 0:00 - 1:51
Jumping To The Brute Force 1:51 - 2:52
Optimizing Our Search 2:52 - 4:14
We Need To Notice Something... 4:14 - 5:49
The Data Does Not Dictate How We Interpret It 5:49 - 7:28
Establishing Our Mapping System 7:28 - 11:03
Executing The Binary Search 11:03 - 15:10
Runtime of Our Binary Search 15:10 - 15:45
The Problem Introduction (Variant 2) 15:45 - 16:43
Jumping To The Brute Force 16:43 - 17:15
The #1 Key To Search Problems 17:15 - 19:08
Defining Our Fundamental Decision Operation 19:08 - 20:57
Searching For Places To Start Our Search 20:57 - 22:48
Search Example #1 (Bottom Left Starting Point) 22:48 - 24:37
Search Example #2 (Top Right Starting Point) 24:37 - 25:38
What Just Happened 25:38 - 26:19
Analyzing Our Incremental Approach 26:19 - 28:34
Wrap Up 28:34 - 29:11

The code for both variants is in the description, fully commented for understanding purposes.

BackToBackSWE
Автор

As a beginner, this channel is such a goldmine. The way you explain complex topics in a easy intuitive way is really amazing wow man

gradientO
Автор

Just got my FB swe intern offer yesterday! Your vids help out a ton man.

yusefmustafa
Автор

Astounded this has < 10k views. By far the best content on these topics I've come across. Keep grinding Ben!

joshhwb
Автор

Haven't commented on a coding explanation video before but this is actually the best channel ever. I was struggling so hard with this problem until this video and this made everything seem so easy. Thank you so much, please never stop creating this amazing content.

saadtajwar
Автор

"Reducing the search space..." - such a nice insight! Thanks man your lessons made me more confident.

kharinskiyalexey
Автор

Oh man!!! You are awesome!!! Lots people can write perfect code but not many of them can express their ideas and especially make others understand the code and why write the code this way.. but you MADE IT!!!! "Reducing the search space." You are genius!!! Thanks for all your hard working!!!

liyingyin
Автор

He has a magic of explaining dsa problems very well.

ishanshah
Автор

Whenever I can't understand any question and see that you have done a video on it already .. I feel so relieved!! Thanks for such awesome videos!
Could you also make videos on how should we present the solution to questions asked in coding interviews ?

gssnhimabindu
Автор

The solution feels effortless once I have been through your videos! Thanks so much! :)

aprajitajha
Автор

It took so much time for me to find someone on youtube like you who can explain in so much depth. There are lots of channels who explains the direct solutions but those are not really helping. You are the real hero who helps us to build the correct logic.

Thank you so much. Keep making such good videos.

ravipatel-xuqi
Автор

dude I have read many tutorials and discussions on this question but no one has actually explained why we choose top right or bottom left like you did. you're just awesome man

charan
Автор

Keep doing what you're doing... please. You're so clear on explanations and without showing me code, I'm understanding the concepts of these questions so much more now. I wish I stumbled on these sooner. I'm actively applying right now as a graduating senior. I am not having much luck landing interviews due in part to my lack of an internship... but I'm hoping going through these practices will help me slam dunk whatever interview comes my way some day. Thank you!

bendevenport
Автор

Just stumbled upon this video and have to say youre one of the best teachers for computer science I have seen.

bubsterbrandino
Автор

One of the best explanations or walkthroughs I have ever seen for any problem.

cristianouzumaki
Автор

This channel has best explainations, the way he approaches, starts from brute-force, slowly move to optimal with clearly explaining each move, makes coding feel very easy. Love the contents. plz dont't stop, keep making the videos, of-course this channel can become the world's largest swe resource.

farizma
Автор

Sir,
Your videos are AWESOME, nothing can be better than this!!! ...
could you please do some videos on system design

khssameernew
Автор

I’m glad I found your YouTube channel last night cuz I’ve been stuck on this problem for a while lol. 🙏🏾

Hasansaid
Автор

Carry on, bro. Your algo video is really different and effective than the other guys on the youtube. Others just give the solution but you are the one who tries to explain the reasons behind the solution.

shakawatabsar
Автор

The second variant was asked in Amazon coding test

piyushmajgawali