No video

Spiral Matrix

  Рет қаралды 45,403

Kevin Naughton Jr.

Kevin Naughton Jr.

Күн бұрын

Пікірлер: 75
@KevinNaughtonJr
@KevinNaughtonJr 4 жыл бұрын
spirals are FUN instagram: instagram.com/kevinnaughtonjr/ twitter: twitter.com/kevinnaughtonjr
@randeepsiddhu
@randeepsiddhu 4 жыл бұрын
This is how you realize the importance of meaningful variable names
@Srijeet040689
@Srijeet040689 3 жыл бұрын
Absolutely beautiful! Kudos for the explanation, and for choosing meaningful variable names :)
@ahasunos5914
@ahasunos5914 2 жыл бұрын
I had the same approach to solve the problem but struggled for 3 hours because of the variable names. Thanks Kevin.
@shwetagoel31
@shwetagoel31 4 жыл бұрын
This is one of the cleanest solutions! Many thanks!
@OverLordOfDa3rdWorld
@OverLordOfDa3rdWorld 4 жыл бұрын
Wow, I thought about doing it this way but was afraid to because I thought the numerous for loops inside the while loop seemed wrong but apparently not lol Thanks Kevin! Just one question, why have the same check inside the for loops when the while loop does it for you ?
@louistannudin2486
@louistannudin2486 3 жыл бұрын
The nums.size() < size check is to help with dealing with certain edge cases that makes the algo (for some odd reason) run backwards like this case: [[1,2,3,4],[5,6,7,8],[9,10,11,12]] without the check, the output is: [1,2,3,4,8,12,11,10,9,5,6,7,6] which is incorrect
@chintalapativenkataramarahul
@chintalapativenkataramarahul 3 жыл бұрын
I think we need to check the same condition for all for-loops because the ArrayList may get filled mid-way of the while loop(i.e maybe after running only left to right or after top to bottom) and in that case, we don't want the rest of the for-loops to run in that iteration.
@itsbenteller1
@itsbenteller1 2 жыл бұрын
Such a clean solution. Thank you!
@subhamagarwal476
@subhamagarwal476 2 жыл бұрын
watched it once and got it . Thanks kevin.
@dhruvseth
@dhruvseth 4 жыл бұрын
Hello great video Kevin, can you please explain why you had the && res.size() < size check condition with every for loop, I am a little lost. Thank you!
@darod6098
@darod6098 4 жыл бұрын
Thank you for all your work man :) I'm going to have an interview for interning at Facebook this month. First missing positive of LC or more videos related to Binary Search and strategies to apply on arrays would be AWESOME. Thank you.
@ri7_cars
@ri7_cars 4 жыл бұрын
This is a clean solution, very easy to understand and implement
@igornesterov711
@igornesterov711 3 жыл бұрын
Thanks! Great explanation! And as already mentioned deal in variable names!
@surabhipriya4333
@surabhipriya4333 4 жыл бұрын
got this question for my interview today.. Wish i had seen this before.
@mohanaravind7656
@mohanaravind7656 3 жыл бұрын
Did you end up getting the job? and what company gave this question?
@surabhipriya8386
@surabhipriya8386 3 жыл бұрын
@@mohanaravind7656 Microsoft ! No I got rejected in their final round
@southece
@southece 3 жыл бұрын
Same with me. I got this question in interview. I was not able to solve it and got rejected. Interview had only this question.
@PallNPrash
@PallNPrash 3 жыл бұрын
v nice Kevin...like the way you explain your logic, even as you are typing the solution
@Wisekuma
@Wisekuma 2 жыл бұрын
What is the practical application of doing this - other than for a job interview?
@vivekkumarmaheshwari3007
@vivekkumarmaheshwari3007 2 жыл бұрын
This is the best solution because the approach seems pretty obvious.
@PramodRj
@PramodRj 2 жыл бұрын
Good JOb Kevin.
@pewdiepieschair2693
@pewdiepieschair2693 3 жыл бұрын
You sir are an absolute legend
@mailtobasit74
@mailtobasit74 3 жыл бұрын
Thanks a lot
@lakshaygupta6180
@lakshaygupta6180 3 жыл бұрын
Thanks Kevin!! .... nice explanation
@leanobajio
@leanobajio 4 жыл бұрын
lovely work, Kev!
@KevinNaughtonJr
@KevinNaughtonJr 4 жыл бұрын
Dean thanks Dean!
@mnchester
@mnchester 2 жыл бұрын
amazing explanation!
@sumitanglekar6309
@sumitanglekar6309 4 жыл бұрын
You just made it look so easy again 🙌 Kudos
@lordmill4572
@lordmill4572 3 жыл бұрын
dude you are genius
@abhishekmulay759
@abhishekmulay759 4 жыл бұрын
Amazing video. Keep up the good work.
@Homelander007
@Homelander007 4 жыл бұрын
Thanks Kevin . can you plz upload this: 1192 Critical Connections in a Network
@KevinNaughtonJr
@KevinNaughtonJr 4 жыл бұрын
I've got it on my list :)
@akshayavenkatesan2912
@akshayavenkatesan2912 4 жыл бұрын
Please do this ASAP
@mohammedatique8389
@mohammedatique8389 2 жыл бұрын
thanks
@chintalapativenkataramarahul
@chintalapativenkataramarahul 3 жыл бұрын
Thank you!
@naveen.v1090
@naveen.v1090 2 жыл бұрын
thank u
@kamalkumar7133
@kamalkumar7133 3 жыл бұрын
whole code in a single screen. GREAT
@aswink1505
@aswink1505 4 жыл бұрын
love your coding videos.thanks for your help. I have a quick question. If you have 5+ years of software engineer experience, should we only expect medium or hard problems?
@KevinNaughtonJr
@KevinNaughtonJr 4 жыл бұрын
Thanks Aswin and honestly I think it varies regardless your level of experience...i kind of think the level of difficulty you get is up to chance...but for system design interviews I think the more experience you have the more they'll expect from you!
@aswink1505
@aswink1505 4 жыл бұрын
got it. thanks for the info
@KevinNaughtonJr
@KevinNaughtonJr 4 жыл бұрын
@@aswink1505 anytime
@ishanrtripathi
@ishanrtripathi 4 жыл бұрын
Hi Kevin, Can you tell me what software you use to edit the videos with the music in the beginning and the end. Is it some mobile app or some Adobe software ?
@shubamsharma5745
@shubamsharma5745 4 жыл бұрын
Thankyou sir for awesome and such beautiful explanation.
@all-open-source
@all-open-source 4 жыл бұрын
Awesome. Seems like the easiest method you come up with.
@danielzuzevich4161
@danielzuzevich4161 3 жыл бұрын
Ty
@anirudhatalmale5575
@anirudhatalmale5575 4 жыл бұрын
awesome solution
@sumitghewade2002
@sumitghewade2002 4 жыл бұрын
Thank you so much for breaking it down so neatly.
@varunsadhu9060
@varunsadhu9060 4 жыл бұрын
Hey , i guess the 2nd for loop instead of top it should be [i]
@KevinNaughtonJr
@KevinNaughtonJr 4 жыл бұрын
that's what I meant to do :/
@vishweshthakur2234
@vishweshthakur2234 4 жыл бұрын
i think in second loop of for where list is added , it should be nums.add(matrix[i][right]) ; in place of nums.add(matrix[top][right]) , else it will repeat 6
@sowmyasg8127
@sowmyasg8127 4 жыл бұрын
finallyyy understoodd :)) thankss a lott
@kevinjohn553
@kevinjohn553 Жыл бұрын
duddddeeeeee, I was replaying the video SOOO many times cause i didn't understand why we wrote matrix[top][right] and not matrix[ i ][right]!! and then when i gave up and continued the video it was corrected. F in the chat
@swati8539
@swati8539 4 жыл бұрын
hey kevin can u suggest coding sites apart from leetcode for entire preparation for google or Amazon or Microsoft interview. thanks 🙂
@KevinNaughtonJr
@KevinNaughtonJr 4 жыл бұрын
I personally think LeetCode is the best but you can also check out hacker rank for other questions and pramp for mock interviews! If you need help preparing or want to practice mock interviews etc I offer those services too here: www.patreon.com/KevinNaughtonJr
@SpectatorAlius
@SpectatorAlius 4 жыл бұрын
The inotro and outro music are rather goofy, but it is *so* nice to hear an algorithm explained in normal, US accent English instead of, well, you know!
@KevinNaughtonJr
@KevinNaughtonJr 4 жыл бұрын
SpectatorAlius if you like my explanations check out the interviewing service I just released thedailybyte.dev/?ref=kevin
@DaKingOfBall23
@DaKingOfBall23 3 жыл бұрын
this one doesnt work, but the one on your github does. this one works for 3x3 but not for 3*4
@ravicrazyster
@ravicrazyster 2 жыл бұрын
yup, it doesn't work for 3*4
@abhinavghosh725
@abhinavghosh725 4 жыл бұрын
hey kevin! what kind of a moustache is that!
@rohananjaria1009
@rohananjaria1009 3 жыл бұрын
You look like Ozan Kabak from Liverpool FC
@riya6549
@riya6549 2 жыл бұрын
so my uni wants to print a matrix in a spiral form...but the matrix is a 3D lmao
@y.5107
@y.5107 Жыл бұрын
holy shit I fail doing it in 2d
@kyle7382
@kyle7382 3 жыл бұрын
function createMatrix(n, m = n) { let i = 1; return new Array(m).fill(null).map(() => { return new Array(n).fill(null).map(() => i++) }) } function spiralTraverseMatrix(matrix) { const items = []; if (!matrix.length) return items; let top = 0; let bottom = matrix.length - 1; let left = 0; let right = matrix[0].length - 1; const size = (bottom + 1) * (right + 1); while( top
@Oscar-ig2gm
@Oscar-ig2gm 3 жыл бұрын
I wrote the same solution)
@kunalkavthekar3747
@kunalkavthekar3747 4 жыл бұрын
hey Kevin, great work on these problems, helped me understand a lot of patterns. can you just link the songs that you put in your videos? you have a great playlist!
@Simple_person221
@Simple_person221 4 жыл бұрын
Its wrong answer, even your screen says it wrong answer, just compare output and expected output
@davidpham6330
@davidpham6330 4 жыл бұрын
Used to watch Indians teach on KZfaq. Now I watch Kevin. I love you
@KevinNaughtonJr
@KevinNaughtonJr 4 жыл бұрын
thanks for the support David!
@bismeetsingh352
@bismeetsingh352 4 жыл бұрын
I solved recursively: leetcode.com/problems/spiral-matrix/discuss/847626/Recursive-Solution
@penmaniac
@penmaniac 3 жыл бұрын
There are all Indians in The Comment section 😂😂😂😂
@kicksomeup6998
@kicksomeup6998 2 жыл бұрын
Wow, the nums.size() check was amazing.
Reorganize String
12:44
Kevin Naughton Jr.
Рет қаралды 77 М.
Validate Binary Search Tree
8:00
Kevin Naughton Jr.
Рет қаралды 50 М.
Кадр сыртындағы қызықтар | Келінжан
00:16
PEDRO PEDRO INSIDEOUT
00:10
MOOMOO STUDIO [무무 스튜디오]
Рет қаралды 8 МЛН
Spiral Traversal of a Matrix | Spiral Matrix
16:33
take U forward
Рет қаралды 194 М.
Shortest Way to Form String
11:25
Kevin Naughton Jr.
Рет қаралды 28 М.
i lost my job as a software engineer...
12:35
Kevin Naughton Jr.
Рет қаралды 22 М.
Rotting Oranges
15:44
Kevin Naughton Jr.
Рет қаралды 64 М.
Unique Paths
7:07
Kevin Naughton Jr.
Рет қаралды 60 М.
How Coding Will Change Your Life
11:13
Kevin Naughton Jr.
Рет қаралды 8 М.
Minimum Path Sum
8:52
Kevin Naughton Jr.
Рет қаралды 56 М.
LeetCode Spiral Matrix Solution Explained - Java
11:07
Nick White
Рет қаралды 48 М.