LeetCode Spiral Matrix II Solution Explained - Java

  Рет қаралды 14,341

Nick White

Nick White

Күн бұрын

Пікірлер: 14
@culleyb
@culleyb 4 жыл бұрын
Excellent video. Thank you Nick for making these videos. Below is an alternative solution I developed. It uses a single "level" tracker, rather than the row start + end and column start + end trackers. Each level is one "spiral" around the outside edge of the currently active region. public int[][] generateMatrix(int n) { int[][] matrix = new int[n][n]; int level = 0; int currentNumber = 1; while (level = level; i--) { int rowIndex = n - level - 1; matrix[rowIndex][i] = currentNumber++; } // fill in left side column for (int i = n - level - 2; i > level ; i--) { /* the "> level" bound takes care of not overlapping with the top row that's already been filled in for tis level */ matrix[i][level] = currentNumber++; } level++; } return matrix; }
@indiansoftwareengineer4899
@indiansoftwareengineer4899 4 жыл бұрын
thanks Brad.
@user-pr6lv7nd6l
@user-pr6lv7nd6l 3 жыл бұрын
I did the same way
@Demonic79221
@Demonic79221 Жыл бұрын
Thanks for the simple and clear explanation! This solution is easy understanding than LeetCode Editorials.
@satyamgupta6030
@satyamgupta6030 Жыл бұрын
thanks alot nick already saw the last video just saw this video if I could learn something new and guess what I did thanks.
@mertyertugrul
@mertyertugrul 4 жыл бұрын
Thank you good work 👍
@millionaires1
@millionaires1 3 жыл бұрын
Nice explanation
@velmuruganr9321
@velmuruganr9321 3 жыл бұрын
buddy can you do spiral 3 in leetcode?
@deepeshgurnani1671
@deepeshgurnani1671 2 жыл бұрын
Hi, Great video Can you make a video for spiral matrix 3 885 leetcode medium ?
@miguelballen4119
@miguelballen4119 5 жыл бұрын
Nice solution
@hhjdkdnchidnd
@hhjdkdnchidnd 3 жыл бұрын
Hi Nick can you make a video for Spiral Matrix III (885)? I am still confused it. Thank you
LeetCode Spiral Matrix Solution Explained - Java
11:07
Nick White
Рет қаралды 49 М.
Spiral Traversal of a Matrix | Spiral Matrix
16:33
take U forward
Рет қаралды 261 М.
$1 vs $500,000 Plane Ticket!
12:20
MrBeast
Рет қаралды 122 МЛН
Sigma girl VS Sigma Error girl 2  #shorts #sigma
0:27
Jin and Hattie
Рет қаралды 124 МЛН
Valid Palindrome II
7:58
Kevin Naughton Jr.
Рет қаралды 33 М.
Spiral Matrix - Microsoft Interview Question - Leetcode 54
16:46
Making an Algorithm Faster
30:08
NeetCodeIO
Рет қаралды 197 М.
Self Taught Programmers... Listen Up.
11:21
Nick White
Рет қаралды 1,1 МЛН
Python laid waste to my C++!
17:18
Sheafification of G
Рет қаралды 193 М.
How Senior Programmers ACTUALLY Write Code
13:37
Thriving Technologist
Рет қаралды 1,6 МЛН
Coding Challenge 167: Ulam Spiral of Prime Numbers
24:13
The Coding Train
Рет қаралды 756 М.
$1 vs $500,000 Plane Ticket!
12:20
MrBeast
Рет қаралды 122 МЛН