885. Spiral Matrix III | matrix | Leetcode Daily Challenge | DSA | Hindi

preview_player
Показать описание
Problem Name:
885. Spiral Matrix III

Problem Statement:
You start at the cell (rStart, cStart) of an rows x cols grid facing east. The northwest corner is at the first row and column in the grid, and the southeast corner is at the last row and column.

You will walk in a clockwise spiral shape to visit every position in this grid. Whenever you move outside the grid's boundary, we continue our walk outside the grid (but may return to the grid boundary later.). Eventually, we reach all rows * cols spaces of the grid.

Return an array of coordinates representing the positions of the grid in the order you visited them.

Problem Link:

Solution Link:

Spiral Matrix 1 and 2:

Graph Playlist:

Java Plus DSA Placement Course Playlist:

Java Plus DSA Sheet:

Notes:

Telegram Link:

Ultimate Recursion Series Playlist:

Samsung Interview Experience:

Company Tags:
Facebook | Amazon | Microsoft | Netflix | Google | LinkedIn | Pega Systems | VMware | Adobe | Samsung

Timestamp:
0:00 - Introduction
1:03 - understanding the problem
7:35 - code
13:57 - Algorithmic Analysis

#ShashwatTiwari #coding​​ #problemsolving​
Рекомендации по теме
Комментарии
Автор

The best explanation in the entire youtube... Thanks

gautamjangir
Автор

like target for this video is 120, Please do like if you have understood the explanation as well as the code.😄😄

shashwat_tiwari_st
Автор

watching you for the first time, your voice and slow explanation helps me understand the problem, thank you sir/buddy <3

kushsharma
Автор

Bhaiya thanks for taking Algorithm Analysis so deeply. We would love to have such discussion on time complexity and space in your future future daily videos. For that, we would definitely like to spend more 5 to 10 mins watching your videos! 😃

SpamUser-kt
Автор

Could you Rectify the TC once? According to my Observation
It is Related to steps(Spiral Length at the time ).
Sum From (1 to Final_Steps)*2 (Nearer Or Exact to that) and
that can Differ According to Initial Location and matrix Size

rohanjuneja
Автор

I ma a beginner learning java in my mereko Samajne me diktat ja rahi plz suggest what to do

krishna-gfpg
Автор

bhai mera ans thoda causal hai in c++ ::=> class Solution {
public:
vector<vector<int>> spiralMatrixIII(int rows, int cols, int rStart, int cStart) {
vector<vector<int>>res;
int r = rStart, c = cStart;
int inc = 1;
res.push_back({r, c});
while(res.size() < rows * cols){
// if((inc & 1) == 1){
for(int i = 0; i < inc; i++){ // for right direction
c++;
if((r >=0 && r < rows) && (c >= 0 && c < cols)) res.push_back({r, c});
}
for(int i = 0; i < inc; i++){ // for down direction
r++;
if((r >=0 && r < rows) && (c >= 0 && c < cols)) res.push_back({r, c});
}
inc++;
// }
// else{
for(int i = 0; i < inc; i++){ // for left direction
c--;
if((r >=0 && r < rows) && (c >= 0 && c < cols)) res.push_back({r, c});
}
for(int i = 0; i < inc; i++){ // for up direction
r--;
if((r >=0 && r < rows) && (c >= 0 && c < cols)) res.push_back({r, c});
}
// }
inc++;
}
return res;
}
};

Editors_Choice