LeetCode Spiral Matrix II Solution Explained - Java

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

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.
@millionaires1
@millionaires1 2 жыл бұрын
Nice explanation
@hhjdkdnchidnd
@hhjdkdnchidnd 2 жыл бұрын
Hi Nick can you make a video for Spiral Matrix III (885)? I am still confused it. Thank you
@deepeshgurnani1671
@deepeshgurnani1671 2 жыл бұрын
Hi, Great video Can you make a video for spiral matrix 3 885 leetcode medium ?
@velmuruganr9321
@velmuruganr9321 3 жыл бұрын
buddy can you do spiral 3 in leetcode?
@mertyertugrul
@mertyertugrul 4 жыл бұрын
Thank you good work 👍
@miguelballen4119
@miguelballen4119 5 жыл бұрын
Nice solution
LeetCode Spiral Matrix Solution Explained - Java
11:07
Nick White
Рет қаралды 49 М.
Spiral Matrix - Microsoft Interview Question - Leetcode 54
16:46
Support each other🤝
00:31
ISSEI / いっせい
Рет қаралды 81 МЛН
So Cute 🥰 who is better?
00:15
dednahype
Рет қаралды 19 МЛН
小丑女COCO的审判。#天使 #小丑 #超人不会飞
00:53
超人不会飞
Рет қаралды 16 МЛН
Alimentos em inglês - Food in English
7:41
Tereza Carvalho
Рет қаралды 69
LeetCode Max Area of Island Solution Explained - Java
9:21
Nick White
Рет қаралды 13 М.
I Got Rejected (again)
9:43
Nick White
Рет қаралды 206 М.
Spiral Matrix III - Leetcode 885 - Python
10:51
NeetCodeIO
Рет қаралды 13 М.
885. Spiral Matrix III - Day 8/31 Leetcode August Challenge
17:32
Programming Live with Larry
Рет қаралды 922
LeetCode Search A 2D Matrix Solution Explained - Java
11:47
Nick White
Рет қаралды 39 М.
I Solved 100 LeetCode Problems
13:11
Green Code
Рет қаралды 289 М.
LeetCode 56. Merge Intervals (Algorithm Explained)
12:57
Nick White
Рет қаралды 91 М.
struct Basics | C Programming Tutorial
24:44
Portfolio Courses
Рет қаралды 157 М.
LeetCode 238. Product of Array Except Self (Solution Explained)
14:49
Support each other🤝
00:31
ISSEI / いっせい
Рет қаралды 81 МЛН