No video

Spiral Traversing A Matrix Solution ( LeetCode #54 ) | FREE DSA Course in JAVA | Lecture 85

  Рет қаралды 5,857

TAP ACADEMY

TAP ACADEMY

Күн бұрын

It is an interesting question where we have to traverse a matrix in a spiral format.
So the question is, we have to write a program to print the elements of a given 2D array/matrix of size m*n in spiral order.
So for the matrix,
1,2,3,
4,5,6
7,8,9
The output will be 1,2,3,6,9,8,7,4,5.
Let's see how we can come up with an approach to deal with this program and solve it.
Hint - We are again and again moving in a pattern as left to right, top to bottom, right to left, and bottom to top. You have to use this pattern to approach the program.
Subscribe ‪@TAPACADEMY‬
For more information, fill this form: forms.gle/8eiU...
or call us at 8884881203
Facebook: / thetapacademy
Instagram: / tapacademy_online
Linkedin: / 73820805
Website: www.thetapacad...​

Пікірлер: 11
@user-hx1kp8kr4m
@user-hx1kp8kr4m 2 ай бұрын
Excellent Explanation Sir
@KRajesh-ej7dy
@KRajesh-ej7dy Жыл бұрын
Sir Excellent Explination
@Raubritterr222
@Raubritterr222 4 ай бұрын
sir, I am saying, this is the best explanation of spiral matrix! ...I hope its clear 😉
@akarshgupta4981
@akarshgupta4981 11 ай бұрын
Great explanation! Thank you soo much.
@user-bu4rv9od7b
@user-bu4rv9od7b Жыл бұрын
superb explanation sir.
@hari7110
@hari7110 7 ай бұрын
great explanation bro
@paisastocks8363
@paisastocks8363 11 ай бұрын
Perfect 💯
@manoranjankumarjha3776
@manoranjankumarjha3776 10 ай бұрын
class Solution { public List spiralOrder(int[][] matrix) { ArrayListres = new ArrayList(); int top = 0, bottom = matrix.length-1; int left = 0,right = matrix[0].length-1; while(left>> right top are constant for(int i=left;ibottom for(int i = top;i>>left for(int i=right;i>=left;i--) { res.add(matrix[bottom][i]); } bottom--; // bottom---->>>top for(int i = bottom;i>=top;i--) { res.add(matrix[i][left]); } left++; } return res; } }
@kethavatharyan3255
@kethavatharyan3255 11 ай бұрын
Great
@Arjunsingh-cf7nf
@Arjunsingh-cf7nf Жыл бұрын
owsome question
@saurabhdwivedi7699
@saurabhdwivedi7699 8 ай бұрын
Can anyone please explain me my whole code is same but when i write :- ( result.add(arr[i][right] ); It is showing me error that the type java.util.AbstractList cannot be resolved
Java Tutorial for Beginners (Part 1) | TAP Academy
2:19:33
TAP ACADEMY
Рет қаралды 119 М.
Seeds of Growth (1111hz) | 1 hour handpan music | Malte Marten
1:04:32
Malte Marten
Рет қаралды 7 МЛН
Unveiling my winning secret to defeating Maxim!😎| Free Fire Official
00:14
Garena Free Fire Global
Рет қаралды 16 МЛН
Just Give me my Money!
00:18
GL Show Russian
Рет қаралды 990 М.
RA3AAE: "Как передаётся энергия".
37:42
Pretty Good Roast Show S1. EP 3/7 |  Ft.  Huma Qureshi
47:29
Aashish Solanki
Рет қаралды 8 МЛН
LeetCode 885: Spiral Matrix III - Interview Prep Ep 33
25:57
Fisher Coder
Рет қаралды 10 М.
Uncle Logic- A Stand Up Special
56:49
Kunal Kamra
Рет қаралды 2,9 МЛН
Unveiling my winning secret to defeating Maxim!😎| Free Fire Official
00:14
Garena Free Fire Global
Рет қаралды 16 МЛН