Koi baat nahi bhaiya. Your efforts are unmatched. Aur acha hi hua ki nhi dala video. Pichla 2 video karne me itna dimaag laga ki 2 din usi me lag gaya 🤣😂😂
In spiral order traversal, those who are getting 29 twice in the output, actually you'll have to add a check before the inner last two for loops to prevent unnecessary iterations. Code: ``` #include using namespace std; using ll = long long; int main() { int n, m; cin >> n >> m; int arr[n][m]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> arr[i][j]; } } // spiral order traversal int row_start = 0; int col_start = 0; int row_end = n - 1; int col_end = m - 1; int cnt = n * m; // To count total elements left for printing while (row_start
yes i also got the repeat of 29 using the original code so a simple solution to this is use a count that is row*column and - it for every element printed and if count==0 stop loop break out and prevent any of the inner loops from running ! did the job !
Corrected last code(spiral traversal) #include using namespace std; int main() { int n,m; cin>>n>>m; int a[n][m]; for(int i=0;ia[i][j]; } } int row_start=0,col_start=0,row_end=n-1,col_end=m-1; while(row_start
#include using namespace std; int main() { int n,m; cin>>n>>m; int a[n][m]; for(int i=0;ia[i][j]; } } //for spiral order print int row_start=0,row_end=n-1,column_start=0,column_end=m-1; while(row_start
well i think you should take a look at this a bit less complex to comprehend and solves the same bug that video's code had (that if we enter an array of sizes let's say r (odd num) and c (consecutive odd num) then it will provide r*c + x(unknown) number of elements as spiral output instead of r*c so here's my version but simpler than yours #include using namespace std; int main() { int r,c,minr=0,minc=0; cin>>r>>c; int maxr=r-1,maxc=c-1; int a[r][c]; for(int i=0;ia[i][j]; } } int count=0; while(count < r*c) { for(int i=minr;i
2D array declare a[n][m] se krte hai aur n rows ke liye hota hai aur m columns ke liye input lene ke liye for(i=0 se n-1) ke andar for(j=o se m-1) me cin krenge similar for cout aur simple search ke liye bhi wahi karenge Now printing in spiral order me ham 4 parameters lete hai row_start=0 row_end= n-1 col_start=0 aur col_end= m-1 while(Rs
hey! I dont think that an if statement is necessary here as the for loop itself checks the condition first. This code works perfectly fine with rectangular matrices.
@@shivikabahri7113The code discussed in this video is not working for rectangular matrix. I submitted this code on gfg and it gave WA for testcase of 3*5 matrix
Thank you Apna College Team for making me understand the code so well. I am glad I found your channel. You guys are doing a great job. More power to you.
@Apna College in the last code, the final output must also contain '29' after '30' . i code the same program in my lappy and it showed 29 after 30 cuz the "third" for loop inside while loop will execute one more time as the condition would hold true in the THIRD for loop. SEE BELOW for( int row=2; row>=2; row - -) { cout
We tremendously appreciate aman bhaiya..You are doing a huge help to us thank you thank you very much..Bhaya we are eagerly waiting for web dev courses..
Bhaiya, At the end the video, you told us to practice Different types of programming and learn Algorithms. It'll be great if you recommend some sources to practice from.
Thank you apna college team , following this amazing course has been a great experience , however some videos contains advanced level questions but I think they are required to boost up your level and thinking ability. Once again thanking you all for this amazing free content🙏
Extra must know points. You can not directly initialise 2D array as we do in simple array. So we can use memset to initialise it quickly. You can not pass 2d array address to function and use it. Ex. void fun(int & matrix[][] ) { } C++ don’t allow this. So if you want to give reference of 2D array than use different way to initialise it. By making pointer of pointer. int **matrix = new int *[ 10 ] ; for (int i = 0; i
Solution is simple check the condition of while loop inside before using for loop because for some for loops variable changes inside itself. #include using namespace std; int main() { int row, col; cin >> row >> col; //allocate the array int **arr = new int *[row]; for (int i = 0; i < row; i++) arr[i] = new int[col]; cout arr[i][j]; } } cout
You need to put two conditions : After incrementing row_start an if condition should be there if(row_start > row_end) break; Similarly after decrementing the column_end check if(column_start>column_end) break;
@@fatmazafar8006 assume row start and row end was same in the beginning so it passed while loop bt after first for loop start increased and it is still gonna go in the third for loop thats why we are checking the condition over there also.
@@_rahulsain Hey I contributed in your git hub repository What a pleasant surprise Do you know I completed this year's hactoberFest challenge Thank you for approving my 2 pull request...
I think this algo prints more content when we have array= {{1,2, 3, 4 }, { 5, 6, 7, 8 }, {9,10,11,12}}; like this. and hence we have to add some conditions. Mu code for this is : - #include #include using namespace std; int main() { int row,col; row = 3; col = 4; int arr[row][col] = { { 1, 2, 3, 4 }, { 5, 6, 7, 8 }, { 9, 10, 11, 12 } }; int row_start = 0; int row_end = row - 1; int col_start = 0; int col_end = col - 1; /* 0 1 2 1 2 3 2 3 4 */ while(row_start
The code given in video for spiral value problem is little incorrect. The correct code is #include #include #include using namespace std; /* */ int main(){ int rows,columns; coutrows; coutcolumns; int arr[rows][columns]; for(int i=0;i
Mostly cmmnt "there's missing if statement" But tell me guyzz When he check same condition at while loop, so why there's need of again if statement for checking same condition??...
Can anyone solve this plzz..??? int X( int N) { if(N < 3) return 1 ; else return X(N-1) + X(N-3) + 1 ; } How many times is the function X is called when (x (5)) is evaluated and what is the value?
i have a doubt, the code given in the video is printing an extra number at the end why is this happening to me and not in the video.. MY CODE IS BELOW.. and if i am including the two if statements at the last two for loops then the answer is coming correct.. PLS tell WHY #include using namespace std; int main() { int n,m; cin>>n>>m; int a[n][m]; for(int i=0;ia[i][j]; } } //for spiral order print int row_start=0,row_end=n-1,column_start=0,column_end=m-1; while(row_start
can anyone of you explain why they have taken n-1 and m-1 instead of taking n and m, because n and m are the no of rows and columns respectively so why have they reduced it by 1?
Due to some technical glitch, we were not able to upload any video from the last 2 days.
Sir bas ek baar bta dia karo andar se daar lagne lgta hai😂
Nice ❤️💚 bhai
Webdev kab aayega bhiaya?
No problem bhaiya. Just upload those now immediately.
Koi baat nahi bhaiya. Your efforts are unmatched. Aur acha hi hua ki nhi dala video. Pichla 2 video karne me itna dimaag laga ki 2 din usi me lag gaya 🤣😂😂
This is the first lecture from this channel that I didn't understand😢😢 otherwise all the videos are very helpful for me but this is...😢😢..😢😢
Me too
In spiral order traversal, those who are getting 29 twice in the output, actually you'll have to add a check before the inner last two for loops to prevent unnecessary iterations.
Code:
```
#include
using namespace std;
using ll = long long;
int main()
{
int n, m;
cin >> n >> m;
int arr[n][m];
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
cin >> arr[i][j];
}
}
// spiral order traversal
int row_start = 0;
int col_start = 0;
int row_end = n - 1;
int col_end = m - 1;
int cnt = n * m; // To count total elements left for printing
while (row_start
Thank you so much mate🫂❤️
thanks for idea
yes i also got the repeat of 29 using the original code so a simple solution to this is use a count that is row*column and - it for every element printed and if count==0 stop loop break out and prevent any of the inner loops from running ! did the job !
thanks brother
Corrected last code(spiral traversal)
#include
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
int a[n][m];
for(int i=0;ia[i][j];
}
}
int row_start=0,col_start=0,row_end=n-1,col_end=m-1;
while(row_start
i want to ask how did you think it
that things might go wrong if you dont apply if conditions in 3rd ,4th 'for' loop
#include
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
int a[n][m];
for(int i=0;ia[i][j];
}
}
//for spiral order print
int row_start=0,row_end=n-1,column_start=0,column_end=m-1;
while(row_start
well i think you should take a look at this a bit less complex to comprehend and solves the same bug that video's code had (that if we enter an array of sizes let's say r (odd num) and c (consecutive odd num) then it will provide r*c + x(unknown) number of elements as spiral output instead of r*c
so here's my version but simpler than yours
#include
using namespace std;
int main()
{
int r,c,minr=0,minc=0;
cin>>r>>c;
int maxr=r-1,maxc=c-1;
int a[r][c];
for(int i=0;ia[i][j];
}
}
int count=0;
while(count < r*c)
{
for(int i=minr;i
why didn't we dynamically input our 2d array here??
@@groundedgamer would u mind explaining your code once more. I am not able to understand your code.
2D array declare a[n][m] se krte hai aur n rows ke liye hota hai aur m columns ke liye
input lene ke liye for(i=0 se n-1) ke andar for(j=o se m-1) me cin krenge similar for cout aur simple search ke liye bhi wahi karenge
Now printing in spiral order me ham 4 parameters lete hai
row_start=0
row_end= n-1
col_start=0 aur
col_end= m-1
while(Rs
There is a bug in Spiral matrix traverse code. You have to also use an if statement " if(row_start
hey! I dont think that an if statement is necessary here as the for loop itself checks the condition first. This code works perfectly fine with rectangular matrices.
@@shivikabahri7113 check for 6x3 matrix.
we can actually even put || instead of && and it still works perfectly
@@shivikabahri7113The code discussed in this video is not working for rectangular matrix. I submitted this code on gfg and it gave WA for testcase of 3*5 matrix
thank you.....u are correct .....now the code will work for big rectangular matrices also
Thank you Apna College Team for making me understand the code so well. I am glad I found your channel. You guys are doing a great job. More power to you.
Rishabh Gupta - A peaceful soul 😂
🤣🤣🤣 sbse upar likha h
2D array declaration -\ 0:15
Taking and Printing Output -\ 2:03
Searching a Matrix -\ 5:15
Spiral Order Matrix Traversal -\ 7:45
Karat karat abhayas te janmat hoye sujan...rasri avat jat te sil par pade Nishan..🔥✌
Keep up the hard work!
This approach is giving TLE on larger Inputs look for a better approach
@Apna College
in the last code, the final output must also contain '29' after '30' . i code the same program in my lappy and it showed 29 after 30 cuz the "third" for loop inside while loop will execute one more time as the condition would hold true in the THIRD for loop. SEE BELOW
for( int row=2; row>=2; row - -)
{
cout
haa mera bhi yahi problem hai......
1 5 7 9 10 11 21 41 70 105 95 81 79 70 40 15 9 6 10 12 13 20 32 68 63 59 55 25 29 30 29
ye last waala 29 extra hai... Code same hai phir bhi....
@@pranchalkushwaha7407 code sahi ni h mai pura din dekhra tha aj sar drd kra dia kaha glti hui mjse lol
I am loving these videos seriously! Finally I am starting to spend the lockdown productively!
Hey there my earlier self, how far are you now in your coding journey?
how far who are now in codding bro!!!
I actually enjoyed this concept..🙋🏻♂
We tremendously appreciate aman bhaiya..You are doing a huge help to us thank you thank you very much..Bhaya we are eagerly waiting for web dev courses..
Bhaiya,
At the end the video, you told us to practice Different types of programming and learn Algorithms.
It'll be great if you recommend some sources to practice from.
Codechef
HackerRank is better for beginners
Leetcode
Thank you apna college team , following this amazing course has been a great experience , however some videos contains advanced level questions but I think they are required to boost up your level and thinking ability.
Once again thanking you all for this amazing free content🙏
spiral order ki explanation super bhaiya:))
Thankyou apna college for the wonderfull content
Thank u so much
Before this video, matrix was hard for me
Shradha didi ki voice sabse clear aati h ! 😊😊
Rishabh Gupta - A peaceful soul
Extra must know points.
You can not directly initialise 2D array as we do in simple array. So we can use memset to initialise it quickly.
You can not pass 2d array address to function and use it.
Ex.
void fun(int & matrix[][] )
{
}
C++ don’t allow this. So if you want to give reference of 2D array than use different way to initialise it. By making pointer of pointer.
int **matrix = new int *[ 10 ] ;
for (int i = 0; i
Woah! Nice comment, Quite useful!
Check the last code for 3*4 matrix, it repeats one(second last) element.
yes buddy so how did u handle this bug!!!???
same doubt bro
Same is happening with me also. What to do?
Solution is simple check the condition of while loop inside before using for loop because for some for loops variable changes inside itself.
#include
using namespace std;
int main()
{
int row, col;
cin >> row >> col;
//allocate the array
int **arr = new int *[row];
for (int i = 0; i < row; i++)
arr[i] = new int[col];
cout arr[i][j];
}
}
cout
@@sameerraj5800 Har for loop mei ">=" ya "
You need to put two conditions :
After incrementing row_start an if condition should be there if(row_start > row_end) break;
Similarly after decrementing the column_end check if(column_start>column_end) break;
When he check same condition at while loop, so why there's need of again if statement for checking same condition??
@@fatmazafar8006 assume row start and row end was same in the beginning so it passed while loop bt after first for loop start increased and it is still gonna go in the third for loop thats why we are checking the condition over there also.
I am a fresher and completed all programming courses from your channel. Thanks bhaiya ✌✌✌
naach AB
Amazing video, best course , but Missing her voice 💓.
padhle bhai
Men will be men
Bhaiya, Please turn on the monetization. It's a humble request. Pleaseeeeeeee.
Why
Yes, plzz u don't need to prove anything to anyone
@@omkarsulebhavikar1338 There is not only one way to earn money bhaiya knows what he is doing and how will he get back his investment
@@_rahulsain Hey I contributed in your git hub repository What a pleasant surprise Do you know I completed this year's hactoberFest challenge Thank you for approving my 2 pull request...
@@St.LaurentDon Hey, nice to hear I am glad
You guys are killing it
Good explanation, at least he was clear this time!✌
I'm getting SIGTERM in received output can you please help??
I think this algo prints more content when we have array= {{1,2, 3, 4 }, { 5, 6, 7, 8 }, {9,10,11,12}}; like this. and hence we have to add some conditions. Mu code for this is : -
#include
#include
using namespace std;
int main()
{
int row,col;
row = 3;
col = 4;
int arr[row][col] = { { 1, 2, 3, 4 },
{ 5, 6, 7, 8 },
{ 9, 10, 11, 12 }
};
int row_start = 0;
int row_end = row - 1;
int col_start = 0;
int col_end = col - 1;
/*
0 1 2
1 2 3
2 3 4
*/
while(row_start
Yes, you're right.
I too came across this case and found the same solution.
I was looking for this solution.In video its wrongly taught.Thank you.
Question was really quiet tough but help to build logic
superb explanation
Rishabh Gupta- a peaceful soul
Bhaiya please daily upload Kiya karo and thanks for such great content ❤️❤️
The notes of the searching array are not yet uploaded and new videos are not coming frequently in this series, please upload soon.
Regards Abhishek.
Hitler reacting to IIT-JEE RESULTS:= ua-cam.com/video/EioB3UK6IRM/v-deo.html
it takes us some time to make the video. We are trying our best.
@@HarshKumar-kv3xs web d ka course kab tak ayega
if i crack an interview; meri first salary to aman bhaiya aur team main jaigi
thank you aman bhaiya ❤
selection pakka hai
Toh is video series k 2 D array tak pahuchane k baad views bahut kam dikh rahe hai... Agar aap yaha tak pahuche toh well done..👍
Manoj kumar :) a peaceful soul🤗
Bhaiya ,please jald se jald saare videos upload kijiye na. It's a request from my side
Hitler reacting to IIT-JEE RESULTS:= ua-cam.com/video/EioB3UK6IRM/v-deo.html
Why both the last videos are not available Aman Bhaiya? Any clue??
Don't worry, they were failed uploads of this lecture (9.1). We have now removed them from the playlist.
@@ApnaCollegeOfficial grateful
Dono bhaiya ne mast padhaya✌🏻🤝
A peaceful soul ❤️❤️
usually, I don't write comments(in any type of content) but sir let me tell u, the explanation in today's video was the best, I ever had.
Rishab Bhaiya OP .... Respect ++
Thank u sir and aman bhaiya best content and explanation😍
Thanks aman bhaiya and team for your hardwork and efforts.🙏
more effective way to take input or output for 2d array time complexity =O(n)
int i = 0;
int limit = 0;
for (int x = 0; x < m * n; x++){
cout
Little bit difficult to understand ,btw you guys are amazing 👍
Who is the lecturer in this video ? He is quite the teacher.
Thanks you Aman bhaiya and your team.
One day I will make app
The code given in video for spiral value problem is little incorrect. The correct code is
#include
#include
#include
using namespace std;
/* */
int main(){
int rows,columns;
coutrows;
coutcolumns;
int arr[rows][columns];
for(int i=0;i
i,j are not initialized so, how will compiler accept them
Good video but you should scroll down before writing code so we can see it clearly
The last code is giving some wrong output,
try input: 1 3
1 2 3
The solution should be 1 2 3 ,but this code gives output 1 2 3 2 1
Two if statements are missing
mast explanation bhaiya
Guys there is a bug for even number of columns, the logic is printing one extra cout at last.. coz as at last, condition col_end and col_start is true
At the end of the video " SUB PHOD DO.......mee......cell phone phod Diya😂😂😀.......
How many of you saw Rishabh Gupta -a peaceful soul 😂😂😇😇😇😇
Why you removed numbering of the videos?Plz. number them again so that we can easily get an access to the old videos .
I think teaching is too fast and lacks explanation for beginners whose first course is this one. Please look into it, else everything is ♥️
Thank you so much 💗💛
God bless you 🙏
When will you upload videos of web development course bhaiya ??
Please upload them..
Matrix is most important for programming lovers❤❤❤
Yeeee,agyi video🤩🤩
CONTENT WAS REALLY HELPFULL, AUDIO WAS NOT CLEAR THO
Haters starts disliking the video.
Monetise kardo bhaiyya. Koi dikkat nahi
Mostly cmmnt "there's missing if statement" But tell me guyzz When he check same condition at while loop, so why there's need of again if statement for checking same condition??...
I am making a project about contact list but our instructor didn't tell about 2-D arrays so,plz give a exemple of contact with this
Best channel yr💖💖💖
2-3 baar lg gye code smajhne m 😂😂😂
I have to make a final project in c++ for university.Can anyone guide me what should i make and which project will be impressive?
bhaiya thoda aur detail me expalin kariye; bahut tez ho raha sab kuch;
AND THANK YOU SO MUCH FOR ALL YOUR EFFORTS.
0:20 2d array and questions
7:45 spiral order matrix traversal
🥲
bhaiya kv volume high ho jata he kv vol bhutt low ho jata hee ,sharee video me uhee same problem he,
,aur sbhh kuch bahutt hi achaa he
Dislikers are the ones who were making handwritten notes😂😂
Spiral array code has a problem. With 5*6 or 5*7 and so on matrices it is not giving a proper answer.
Aman bhaiya python series kab se upload karoge🙏🙏🙏🙏🙏🙂
Can anyone solve this plzz..???
int X( int N)
{
if(N < 3)
return 1 ;
else
return X(N-1) + X(N-3) + 1 ;
}
How many times is the function X is called when (x (5)) is evaluated and what is the value?
Function is getting called 8 times, and the final value is 3
7 times run and answer is 7
Bhaiya bahut achha hai
Last program so epic..
Wao awesome..
Missing Didi"s voice.
@@kumarharsh90 tera man waisa hai. tereko didi nai dikh rha but kuch aur samj jaroor aarha hai, nais.
#Rishab gupta == A peacefull soul
😎😎😎
hello sir some of your video is in private mode can you convert it to public
Please give us some exercises to work on...
Very good , Eng
In spiral matrix question second last number is repeating
Why courses are not on time.,..as per the timeline 🙄🙄
i have a doubt, the code given in the video is printing an extra number at the end why is this happening to me and not in the video.. MY CODE IS BELOW..
and if i am including the two if statements at the last two for loops then the answer is coming correct.. PLS tell WHY
#include
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
int a[n][m];
for(int i=0;ia[i][j];
}
}
//for spiral order print
int row_start=0,row_end=n-1,column_start=0,column_end=m-1;
while(row_start
There are some corner cases for which this spiral matrix code not gonna work.
video is very helpful but your voice is not clear
This was fun
Most of the solutions provided here failed at
Some test cases
Yeh bnda zada sahii
Here u miss corner cases and a check at last 2 for loops
Thanks for your help...🙏🏽
Hitler reacting to IIT-JEE RESULTS:= ua-cam.com/video/EioB3UK6IRM/v-deo.html
remenber here this solution falis for edge case
can anyone of you explain why they have taken n-1 and m-1 instead of taking n and m, because n and m are the no of rows and columns respectively so why have they reduced it by 1?
because index is starting from 0
@@SchrodingerMan ok,thanks rahul