finally understood the last method 😭 it took my day while learning from striver
@nikoo28
3 ай бұрын
Glad it helped!
@mondeepchetry3095
3 ай бұрын
literally, i was having a hard time learning the optimal solution from striver, that shit was like some rocket science to understand.
@nikoo28
2 ай бұрын
everyone has a different style of explaining. Sometimes striver might click better for you...other days it could be mine :)
@Tapadar.Monsur
Жыл бұрын
Please continue with more array questions. Your explanation is top notch.
@yomamasofat413
Ай бұрын
after doing so many leetcode questions like these, sometimes I feel like programming is all these hacks and tricks to make things more efficient. Anybody feels the same way?
@dumbstonks
2 ай бұрын
You explained the optimized part in the best way from all the videos on youtube, thanks!
@NITISHKUMAR-ng4pu
3 ай бұрын
if there is no row or column that has 0 in it and we updated 0 in it from another element then how can we use 1st row and column to make change in whole row and column
@curtdudeanmol9393
Жыл бұрын
this gives incorrect Answer for this result matrix : [[1],[0],[3]] expected : [[0],[0],[0]] output: [[0],[0],[3]] --> this is in leet code , code which I wrote is below , let me know where I made mistake boolean firstRow = false, firstCol = false; // Set markers in first row and first column for(int i=0; i
@nikoo28
Жыл бұрын
try adding print statements in your code to debug, you will then be able to see the state of your matrix at certain stages. That should help to figure out
@curtdudeanmol9393
Жыл бұрын
@@nikoo28 thanks for the reply, figured out the mistake, while checking for 1st column have been comparing I==0 , hence giving wrong answer .
@ashmit9602
17 күн бұрын
there is one edge case which is missed in the last step(3rd one) we are replacing all elements of 1st rows and columns as 0 but what if we change the given example by 1 bit, instead of 0 at matrix[0][0] we put 1 or any non zero then still the solution would come out same but we know the first column should not get 0 in my given example. @Nikhil Lohia pls tell if i am confusing or i am correct
@pratyakshamaheshwari8269
Жыл бұрын
Another solution without using extra space Start row wise first. Select rows one by one and make all the elements of that row -1 except which are 0, if any element in that row is 0. Similariy you have to do the same thing for columns. Now, before returning traverse the matrix and make all the -1 elements 0. public class Solution { public int[][] solve(int[][] A) { int n = A.length, m = A[0].length; for(int i = 0; i < n; i++){ int flag = 0; for(int j = 0; j < m; j++){ if(A[i][j]==0)flag = 1; } if(flag == 1){ for(int j = 0; j < m; j++){ if(A[i][j] != 0) A[i][j] = -1; } } } for(int j = 0; j < m; j++){ int flag = 0; for(int i = 0; i < n; i++){ if(A[i][j]==0)flag = 1; } if(flag == 1){ for(int i = 0; i < n; i++){ if(A[i][j] != 0) A[i][j] = -1; } } } for(int i = 0; i < n; i++){ for(int j = 0; j < m; j++){ if(A[i][j] == -1)A[i][j] = 0; } } return A; } }
@GaganSingh-zz9el
9 ай бұрын
marking them -1 doesnot increase time complexity ??
@tanveerabbas26
Жыл бұрын
that is the only video where I could understand intuition
@honey-xr5kp
6 ай бұрын
wow i really dont like matrix problems. the best solution uses 2 nested for loops and 2 more for loops
@nikoo28
5 ай бұрын
Yes, matrix problems are very wonky.
@sukanshigarg6051
Ай бұрын
You are like less dramatic version of striver .😂❤
@sachinsoma5757
Жыл бұрын
You are a great teacher. That was the best explanation I found so far. Keep teaching.
@nikoo28
Жыл бұрын
Thank you, I will
@Honest_View
2 ай бұрын
Sir, Why we are using Matrix[0].length & Matrix.length in some for loops? What is the difference between them
@sukanshigarg6051
Ай бұрын
One counts the length of columns while the other counts the length of rows
@thefourhourtalk
5 күн бұрын
great explanation
@amanverma8258
Жыл бұрын
Wonderful explanation! Finally got it, sir
@unknownman1
8 ай бұрын
I really like how you've arranged the videos in your playlist. The upcoming videos are somewhat related to the concepts learned in the previous lessons. Thanks!
@nikoo28
7 ай бұрын
Glad you like them!
@sachinsoma5757
Жыл бұрын
The only part I was confused is the for(int i = 1;i
@nikoo28
Жыл бұрын
We only start from i=0 and j=0 for the first for loop, that is when you are setting the markers. After that if you observe the second for loop, we are starting from i=1 and j=1. If you go through the explanation again, we do this so we can use the first row and column to see if there is a zero anywhere in the respective row/column. Hope this helps.
@sachinsoma5757
Жыл бұрын
@@nikoo28 Thanks, understood
@prapti2385
3 ай бұрын
The solution is wrong. Also why did you convert all the remaining elements to zero in the last step? If you take the example from striver's video he particularly said about that element.
@nikoo28
3 ай бұрын
what do you mean when you say the solution is wrong? The solution passes all the given test cases on LeetCode.
@mdshahidansari9126
2 ай бұрын
but sir's video is earlier than his 😅😅
@nikhil2373
Жыл бұрын
Very good explanation, please used to upload frequently, or if you have any community discord or other please tell us
@nikoo28
Жыл бұрын
I don’t have a discord yet…but can explore about it. Can you tell me its advantages and how it will be helpful to my viewers?
@rdrahuldhiman19
4 ай бұрын
Amazing explanation, got the understanding of firstRow and firstCol when I got stuck with the leetcode example where there is only a single 0 in middle of the matrix. Thanks.
@ElectronaMusic
Ай бұрын
thanks!
@baksonyan4ik
Жыл бұрын
Я скачал leetcode Torture (расширение для гугла), после чего там далась эта задача, которую я не мог решить в течении часа, (потому что я не когда не заходил на leetcode) но вы обьяснили эту задачу так быстро и проффесионально. Большое спасибо! I downloaded the Leetcode Torture extension, and then I got this stupid problem that I was struggling with, like, for an hour, but you've solved it in just 20 minutes, and that quickly and professionally... with explained every step of the process. Thank you very much
@nikoo28
Жыл бұрын
Да, рассмотрение проблемы с помощью визуальных эффектов очень помогает. Я так рад, что это было полезно для вас.
@haripriyaveluchamy9449
Жыл бұрын
your explanation is too good keep rocking
@nikoo28
11 ай бұрын
Thank you so much 🙂
@codingwave56
6 ай бұрын
Thanks Helpful!
@Hayat26474
2 ай бұрын
please upload all dsa question , your explaination is best sir
@palspal2329
Жыл бұрын
Only you were able to explain it clearly for me, thanks brother
@nikoo28
Жыл бұрын
so happy to hear that.. :)
@nikhilagrawal9217
3 ай бұрын
Very clear explanation!!. Thanks a lot.
@abhijnasankesha5182
10 ай бұрын
Thanks
@anandchauhan1868
9 ай бұрын
finally after watching many lecture your video is recommended and it's very helpful and clear my concept
@SadhanaSharma
Жыл бұрын
Thank you sir... this is just an amazing approach
@Lord_bobby_
8 ай бұрын
even in the second and third solution Time complexity is M*N , cant we reduce the time complexity to M+N ??
@nikoo28
7 ай бұрын
that will not be possible, because in the worst case you will have to convert all elements to 0. which means going over each element, and that is O(m * n)
@saurabhruikar3196
Жыл бұрын
Please do upload videos regarding graph algorithms your explanation style will make it easy to understand.
@nikoo28
Жыл бұрын
Sure…I am prepping up some material for it. Graphs are a little tricky…so need a little extra time to simplify them.
@fffooccc9801
Жыл бұрын
@@nikoo28 I have a doubt. It is for sure that we can't use the nested loop to iterate but while marking for zeros we have used a nested loop can u please solve my doubt.
@nikoo2805
Жыл бұрын
@@fffooccc9801 you will have to iterate over each element in the matrix atleast once, and it cannot be done without a nested loop. It is the levels of nesting that you want to reduce…you should only have one nested loop..not more than that.
@nikoo28
7 ай бұрын
The complete playlist on graphs is now available: kzitem.info/door/PLFdAYMIVJQHNFJQt2eWA9Sx3R5eF32WPn
@xinyangli7103
5 ай бұрын
sorry have a question, why is this a constant space solution where there are nested loops multiple times? thanks so much
@nikoo28
5 ай бұрын
just using loops does not mean extra space. You are said to be taking extra space when you are using extra memory equivalent to your input size.
@jedex99
Жыл бұрын
we are with u sir thanks for make it so much easy soln
@b_01_aditidonode43
4 ай бұрын
amazing explanation sir!!
@Dhruv_Sharma_123
Жыл бұрын
Thanks understood
@shravanthombre3407
Жыл бұрын
great explanation!!
@nikoo28
Жыл бұрын
Glad you liked it!
@subee128
9 ай бұрын
Thanks
@mohitahlawat455
7 ай бұрын
Great sir ❤
@parthanuj8611
Жыл бұрын
kya baat hai sir maja aa gaya . loved this
@JohnSmith-uu5gp
Жыл бұрын
Great !!!!!
@infinite639
Жыл бұрын
Teaching mast hai bhai aapki
@nikoo28
Жыл бұрын
Let me what other type of questions/topics you want to see.
@infinite639
Жыл бұрын
@@nikoo28 Please make on Arraylist and linkedlist questions And Graphs, dynamic programming, hashset , hashmap
@infinite639
Жыл бұрын
@@nikoo28 i will send you the questions one by one
@nikoo28
7 ай бұрын
The complete playlist on graphs is now available: kzitem.info/door/PLFdAYMIVJQHNFJQt2eWA9Sx3R5eF32WPn
Пікірлер: 71