1 00:00:01,720 --> 00:00:02,410 Hi, everyone. 2 00:00:02,440 --> 00:00:06,840 So today we are going to solve this question, set metrics, zeros. 3 00:00:07,320 --> 00:00:09,110 OK, so what is the question? 4 00:00:09,140 --> 00:00:10,360 So question is very simple. 5 00:00:10,390 --> 00:00:14,770 So basically our input will basically be Emmental and mattocks. 6 00:00:15,070 --> 00:00:21,550 OK, so what we have to do so if there's a zero present, then we have to make an entire Roseto and 7 00:00:21,760 --> 00:00:22,420 column zero. 8 00:00:22,690 --> 00:00:24,790 OK, so for example, zero is here. 9 00:00:24,940 --> 00:00:27,720 So what we'll do, we will make this entire column. 10 00:00:28,360 --> 00:00:30,640 We will make this an entire roseto. 11 00:00:30,850 --> 00:00:36,240 So basically our output will be zero zero zero and zero zero. 12 00:00:36,520 --> 00:00:39,840 Everything else will remain Sim's or one one, one and one. 13 00:00:40,120 --> 00:00:42,580 OK, now let's see this example. 14 00:00:43,330 --> 00:00:45,410 So in this case, zero is present here. 15 00:00:45,640 --> 00:00:47,590 So I will make this Rosero. 16 00:00:47,590 --> 00:00:49,300 I will make this column zero. 17 00:00:49,510 --> 00:00:51,150 OK, so what will be our output? 18 00:00:51,490 --> 00:00:55,780 So will be zero zero zero and here it will be one. 19 00:00:56,150 --> 00:00:58,700 OK, now let us consider this input. 20 00:00:59,170 --> 00:01:02,410 OK, so in this input, zero is present here. 21 00:01:02,710 --> 00:01:05,830 So what I will do, I will make this entire column zero. 22 00:01:06,070 --> 00:01:07,870 I will make this and that. 23 00:01:07,870 --> 00:01:08,450 Rosero. 24 00:01:08,710 --> 00:01:10,520 So basically what will be an output? 25 00:01:10,540 --> 00:01:17,990 So it is zero zero zero zero and zero and we have one one one and one, OK. 26 00:01:18,190 --> 00:01:20,090 Now let us consider this input. 27 00:01:20,350 --> 00:01:23,180 So in this input, zero is present here. 28 00:01:23,200 --> 00:01:28,060 So I will make this and barrero zero, I will make this entire column zero. 29 00:01:28,300 --> 00:01:30,650 OK, so zero is also present here. 30 00:01:30,670 --> 00:01:32,940 So I will make this entire column zero. 31 00:01:33,280 --> 00:01:37,780 I will make this entire I will make this an entire room zero. 32 00:01:37,990 --> 00:01:46,620 So basically our output will be so zero zero zero zero zero zero zero zero. 33 00:01:46,960 --> 00:01:50,570 And here we have four five three and one. 34 00:01:50,950 --> 00:01:53,120 OK, so I hope you understood this question. 35 00:01:53,410 --> 00:01:56,080 So this question is basically present only code. 36 00:01:56,160 --> 00:01:57,790 OK, so this is the question. 37 00:01:57,820 --> 00:02:01,390 We will be then but will basically be I in box. 38 00:02:01,630 --> 00:02:07,610 And if an element is zero, but we have to do we have to make an entire row, an entire column zero. 39 00:02:08,020 --> 00:02:11,030 OK, so we have to do this question in place. 40 00:02:11,260 --> 00:02:12,810 So what is the meaning of in place. 41 00:02:13,120 --> 00:02:16,290 So in place means we have to change this input. 42 00:02:16,810 --> 00:02:18,770 We have to change the given matrix. 43 00:02:18,790 --> 00:02:21,070 OK, we do not need to create another matrix. 44 00:02:21,340 --> 00:02:23,890 So let's say this matrix is a. 45 00:02:23,920 --> 00:02:26,900 So basically we have to do changes in Matrix only. 46 00:02:26,950 --> 00:02:31,320 OK, we don't have to create another Matrix B, so we have to change. 47 00:02:31,330 --> 00:02:33,670 We have to do changes in Matrix only. 48 00:02:34,660 --> 00:02:38,660 And the expected time and space complexity for solving this problem is basically. 49 00:02:38,860 --> 00:02:43,190 So time is Ammann and the space complexities are different. 50 00:02:43,260 --> 00:02:47,230 OK, so this is the expected time and space complexity for this question. 51 00:02:48,070 --> 00:02:50,740 OK, so let's see how we can solve this question. 52 00:02:50,740 --> 00:02:53,890 First, natality brute force approach, the naive approach. 53 00:02:53,970 --> 00:02:56,350 OK, so let us consider an example. 54 00:02:56,530 --> 00:02:59,560 And so let's take an example. 55 00:02:59,560 --> 00:03:06,940 So we have zero, let's say, for one zero three two one five four zero seven and two. 56 00:03:06,970 --> 00:03:08,710 OK, so let's say this is the input. 57 00:03:08,740 --> 00:03:10,650 Now, let us discuss approach number one. 58 00:03:10,660 --> 00:03:12,200 So naive approach. 59 00:03:12,820 --> 00:03:18,580 So what we will do basically, we will store the column and the rule number where the zero element is 60 00:03:18,580 --> 00:03:19,030 present. 61 00:03:19,060 --> 00:03:21,040 OK, so I will store. 62 00:03:21,310 --> 00:03:22,180 I have a vector. 63 00:03:22,300 --> 00:03:29,860 OK, so let's rename it Vector of integers and let's name it are OK and we will have another vector. 64 00:03:30,490 --> 00:03:33,000 It will store the column number of the zero element. 65 00:03:33,040 --> 00:03:34,810 OK, so we will have two vectors. 66 00:03:34,960 --> 00:03:39,310 OK, so first Vector will restore the rule number. 67 00:03:39,340 --> 00:03:41,350 Second, that devils to the column number. 68 00:03:41,560 --> 00:03:45,870 OK, so now let's say trade over the input input matrix. 69 00:03:46,360 --> 00:03:51,310 So this is zero zero one zero two zero. 70 00:03:51,310 --> 00:03:53,380 Column one, column two, column three. 71 00:03:53,650 --> 00:03:55,730 OK, so zero is present here. 72 00:03:55,750 --> 00:04:01,270 So inside the row I will still zero inside column I will store zero zero is basically the index. 73 00:04:01,270 --> 00:04:06,470 OK, so zero to index and zero the index null for one and zero. 74 00:04:06,670 --> 00:04:11,080 So again we have zero zero four zero zero zero zero zero is already there. 75 00:04:11,410 --> 00:04:14,530 And for three if we want to go right. 76 00:04:14,530 --> 00:04:15,080 One more time. 77 00:04:15,100 --> 00:04:15,340 OK. 78 00:04:15,370 --> 00:04:20,029 So basically what we can do, we can instead of creating a vector, we can create a set. 79 00:04:20,839 --> 00:04:24,940 OK, so what is said means basically they will be unique elements. 80 00:04:25,060 --> 00:04:27,160 So insert they will be unique elements. 81 00:04:27,160 --> 00:04:28,280 Not only good will be there. 82 00:04:28,330 --> 00:04:32,620 OK, so for here the number is three, so I will store three. 83 00:04:32,690 --> 00:04:34,690 OK, so suppose I'm using that. 84 00:04:34,870 --> 00:04:38,510 So since I'm using that I will store zero only one time. 85 00:04:38,540 --> 00:04:42,880 So OK, so inside this set the properties you will have only unique elements. 86 00:04:43,750 --> 00:04:44,140 OK. 87 00:04:45,230 --> 00:04:50,000 So now let us consider two or three years, not zero, two is not zero, one is not zero, five is not 88 00:04:50,000 --> 00:04:51,100 zero four, it is not zero. 89 00:04:51,230 --> 00:04:52,360 So we have zero here. 90 00:04:52,610 --> 00:04:53,840 So the rule is two. 91 00:04:53,840 --> 00:04:59,090 So I will write to here and the column number is basically one, so I will write one. 92 00:04:59,570 --> 00:05:01,380 OK, now let's move ahead. 93 00:05:01,400 --> 00:05:02,870 So this is seven and this is. 94 00:05:03,190 --> 00:05:07,010 OK, so now we have our rule and column separately. 95 00:05:07,690 --> 00:05:10,340 OK, so now let us prepare our output. 96 00:05:10,550 --> 00:05:16,080 So for preparing the output, what we will do so we will iterate over the metrics again. 97 00:05:16,130 --> 00:05:18,600 OK, so we will light it. 98 00:05:18,620 --> 00:05:20,390 So this is the first element. 99 00:05:20,400 --> 00:05:29,160 So I have zero ROI zero and also zero zero zero and zero since the wrong number in Brazil. 100 00:05:29,160 --> 00:05:30,620 Also I will write to zero here. 101 00:05:31,160 --> 00:05:33,340 Now let's come to this element. 102 00:05:33,620 --> 00:05:36,050 So column number one or number zero. 103 00:05:36,290 --> 00:05:38,620 So Roy's present column is also present. 104 00:05:38,630 --> 00:05:40,100 So I will write to zero here. 105 00:05:41,540 --> 00:05:49,820 Now, let's come to this Element one so Roys zero columnist, so column is not present, but Roy's present 106 00:05:49,820 --> 00:05:51,950 since Roy's present, I will write to zero here. 107 00:05:52,220 --> 00:05:54,260 OK, welcome to the settlement. 108 00:05:54,650 --> 00:05:59,830 So basically, rule number is zero and no history and both are present. 109 00:05:59,840 --> 00:06:00,950 So I will write to zero. 110 00:06:01,310 --> 00:06:04,400 OK, so now let's come to this Element Elementary. 111 00:06:05,370 --> 00:06:10,690 So rule number one, so rule number one, not present now, caller number zero. 112 00:06:10,710 --> 00:06:13,350 So since zero, president, I will write to zero. 113 00:06:14,620 --> 00:06:22,750 So I have to so far to no one not present, no one present, since no one is present. 114 00:06:22,960 --> 00:06:24,490 So I will write zero here. 115 00:06:24,610 --> 00:06:26,450 OK, now let's move ahead. 116 00:06:26,920 --> 00:06:33,160 So now let's come to this element, element number one, since element number one columnist to do is 117 00:06:33,160 --> 00:06:35,670 not present number one when it's not present. 118 00:06:35,680 --> 00:06:36,760 So I will write one here. 119 00:06:36,760 --> 00:06:37,400 No changes. 120 00:06:37,420 --> 00:06:38,530 I will not make it zero. 121 00:06:38,590 --> 00:06:41,170 OK, now let's come to this element five. 122 00:06:41,410 --> 00:06:43,390 OK, so rule number one. 123 00:06:44,200 --> 00:06:47,350 Rule number one is not present number three. 124 00:06:47,350 --> 00:06:47,620 Yes. 125 00:06:47,620 --> 00:06:48,750 Column number three is present. 126 00:06:48,760 --> 00:06:50,050 So I will write to zero here. 127 00:06:50,290 --> 00:06:52,120 OK, now let's come to this element. 128 00:06:52,130 --> 00:06:55,000 So this is for rule number two. 129 00:06:55,360 --> 00:06:56,820 Lesser number two is present. 130 00:06:56,830 --> 00:06:58,130 So I will write to zero here. 131 00:06:58,810 --> 00:07:02,120 Now, let's come to this element, this holiday zero so you can directly write zero. 132 00:07:02,950 --> 00:07:05,370 This is a limited number seven, rule number two. 133 00:07:05,740 --> 00:07:08,140 So, yes, we have rule number two. 134 00:07:08,140 --> 00:07:09,400 So I will write to zero here. 135 00:07:10,690 --> 00:07:14,350 So we have element to so Roland Burris to I will write zero here. 136 00:07:14,530 --> 00:07:16,720 OK, so this is basically my output. 137 00:07:18,560 --> 00:07:20,030 This will be the output. 138 00:07:20,580 --> 00:07:25,130 OK, so what is the time and the space complexities or time complexities? 139 00:07:25,130 --> 00:07:27,620 And I think we are just starting with the Matrix two times. 140 00:07:27,620 --> 00:07:34,280 So Emman and the space complexities basically for creating this toolset, let's say the space complexities 141 00:07:34,280 --> 00:07:36,080 and blessin OK. 142 00:07:37,500 --> 00:07:43,930 So if you want to check your solution where the solution is wrong, let us verify our solution. 143 00:07:44,310 --> 00:07:47,350 So what will happen now since this is zero? 144 00:07:47,370 --> 00:07:51,810 I will make this entire column zero and I will make this an entire Rosero. 145 00:07:52,860 --> 00:07:56,690 Since I have zero here, I will make this entire column zero. 146 00:07:57,030 --> 00:08:01,680 I will make this entire rule zero since I have zero here. 147 00:08:01,680 --> 00:08:07,410 So I will make this entire column zero and I will make this entire Rosero. 148 00:08:07,860 --> 00:08:09,920 So basically I have zero everywhere. 149 00:08:10,410 --> 00:08:12,750 Only this element will be there. 150 00:08:12,810 --> 00:08:15,420 OK, so I will have only this element, one dressed. 151 00:08:15,480 --> 00:08:16,830 Every element will be zero. 152 00:08:17,670 --> 00:08:21,840 OK, so our solution, our naive approach is basically right. 153 00:08:21,870 --> 00:08:25,350 OK, so this is the time and the space complexity for the naive approach. 154 00:08:25,350 --> 00:08:30,980 But but as you can see, Yarbo, our solution is to solve this question in one space. 155 00:08:31,040 --> 00:08:37,320 OK, we have to solve this question in open space so how we can solve this question in open space. 156 00:08:37,750 --> 00:08:38,340 Let's see. 157 00:08:38,370 --> 00:08:43,620 OK, so now let's discuss about our approach, the second, which is basically the efficient approach. 158 00:08:45,850 --> 00:08:46,800 Efficient approach. 159 00:08:47,040 --> 00:08:52,680 So in this efficient approach, what we will do, so we will make use of first reinforced column. 160 00:08:52,710 --> 00:08:57,390 OK, so make use of first rule and first column. 161 00:08:57,810 --> 00:09:01,120 OK, so let us take an example to understand this approach. 162 00:09:01,530 --> 00:09:08,050 So basically, let's say I have one zero one one one, two, three, four and five. 163 00:09:08,100 --> 00:09:10,050 OK, so this is basically my input. 164 00:09:11,750 --> 00:09:15,360 Now we have to make use of first rule and first column. 165 00:09:15,380 --> 00:09:20,120 OK, so our step number one is basically take two boolean variables. 166 00:09:20,390 --> 00:09:22,670 OK, so take two Boolean variables. 167 00:09:22,970 --> 00:09:26,930 Let's say their names are has zero first row and has zero first column. 168 00:09:27,230 --> 00:09:30,050 OK, so initially both these variables are false. 169 00:09:30,770 --> 00:09:33,710 OK, now let us update their values. 170 00:09:33,890 --> 00:09:39,320 OK, so basically this is my first rule and this is my first column. 171 00:09:39,860 --> 00:09:42,410 OK, so let's get rid of the first rule. 172 00:09:43,100 --> 00:09:46,670 Yes, it is containing a zero element since it is containing a zero element. 173 00:09:46,700 --> 00:09:48,770 So I will update the variable. 174 00:09:49,040 --> 00:09:51,470 OK, now let's start with the first column. 175 00:09:51,830 --> 00:09:55,460 It is not containing as irrelevant, so it will remain false. 176 00:09:56,820 --> 00:09:58,110 It will remain false. 177 00:09:58,950 --> 00:10:06,720 OK, now the second step, second step is basically you will read from the next one common starting 178 00:10:06,720 --> 00:10:08,400 from one common one index. 179 00:10:08,400 --> 00:10:10,500 You will iterate over the complete metrics. 180 00:10:10,860 --> 00:10:17,580 And as soon as you encounter a zero element, so let's say I encounter element to zero at index Ikoma. 181 00:10:18,760 --> 00:10:23,880 OK, so at index I see if I encounter as irrelevant what I will do. 182 00:10:23,940 --> 00:10:34,050 So if I call my G is zero, then basically I will make I will make Ikoma zero zero and I will make zero 183 00:10:34,380 --> 00:10:35,730 G zero. 184 00:10:36,940 --> 00:10:39,250 OK, so what is the meaning of these two lines? 185 00:10:39,850 --> 00:10:43,210 So let us see, so I would like to read from this element. 186 00:10:43,540 --> 00:10:44,830 OK, let's make it zero. 187 00:10:45,220 --> 00:10:46,830 OK, so this is one. 188 00:10:46,840 --> 00:10:47,700 Do not do anything. 189 00:10:47,710 --> 00:10:48,320 This is zero. 190 00:10:48,580 --> 00:10:56,050 So as soon as I encounter a derailment, what I'm doing, I will go to the topmost and I will write 191 00:10:56,050 --> 00:10:56,430 zero. 192 00:10:56,680 --> 00:10:59,720 I will go to the leftmost and I will write zero. 193 00:10:59,810 --> 00:11:02,590 OK, so this is the meaning of this thing. 194 00:11:03,260 --> 00:11:06,510 OK, so this is for do not do anything. 195 00:11:06,520 --> 00:11:07,150 This is five. 196 00:11:07,150 --> 00:11:08,010 Do not do anything. 197 00:11:08,050 --> 00:11:10,000 OK, so our second step is ready. 198 00:11:11,100 --> 00:11:20,220 Now, the third step again started trading from one common when one index, OK, now for every index, 199 00:11:20,910 --> 00:11:33,290 for every index I Komachi, for every index I see if Ikoma zero is zero or zero, comma G is zero, 200 00:11:33,870 --> 00:11:36,510 then make then make. 201 00:11:36,510 --> 00:11:38,460 I got my G equals zero. 202 00:11:38,530 --> 00:11:41,050 OK, so what is the meaning of these lines. 203 00:11:41,100 --> 00:11:42,280 Let us try to understand. 204 00:11:42,960 --> 00:11:44,770 So we will start trading again. 205 00:11:44,820 --> 00:11:47,040 OK, so now let's try it again. 206 00:11:47,220 --> 00:11:48,930 So I have this element one. 207 00:11:49,170 --> 00:11:55,920 OK, so for every index psychology we will check the top most and we will check the leftmost. 208 00:11:56,130 --> 00:11:58,350 If any of them contain zero then right. 209 00:11:58,360 --> 00:11:58,650 Zero. 210 00:11:58,830 --> 00:12:00,810 OK, check the. 211 00:12:01,870 --> 00:12:06,200 But most check the leftmost, so this is I'm checking the top most. 212 00:12:06,520 --> 00:12:08,500 This is I am checking the leftmost. 213 00:12:08,500 --> 00:12:10,510 If any of them is zero, then make a zero. 214 00:12:10,820 --> 00:12:14,080 OK, so this is the top post. 215 00:12:14,110 --> 00:12:14,830 This is the left. 216 00:12:14,830 --> 00:12:16,990 Most voters will also make zero here. 217 00:12:17,440 --> 00:12:19,280 OK, so this is obviously zero. 218 00:12:19,300 --> 00:12:20,210 So do not do anything. 219 00:12:21,250 --> 00:12:27,360 This is for check the leftmost so left is not digital but check the topmost sort of post zero. 220 00:12:27,380 --> 00:12:28,660 So I will write the zero here. 221 00:12:29,590 --> 00:12:31,180 OK, now four five. 222 00:12:31,330 --> 00:12:33,890 The left just three and the top is zero. 223 00:12:33,910 --> 00:12:35,170 So I will write to zero here. 224 00:12:35,530 --> 00:12:38,510 OK, so after that third step, what is my error. 225 00:12:38,710 --> 00:12:41,250 What is my matrix or the condition of my taxes. 226 00:12:41,260 --> 00:12:43,470 One zero zero. 227 00:12:44,230 --> 00:12:45,830 This is one. 228 00:12:46,270 --> 00:12:47,820 OK, so this is basically zero. 229 00:12:48,670 --> 00:12:49,600 This is zero. 230 00:12:49,720 --> 00:12:50,590 This is zero. 231 00:12:50,990 --> 00:12:52,080 This is three. 232 00:12:52,090 --> 00:12:53,230 This is zero. 233 00:12:53,230 --> 00:12:54,010 And this is zero. 234 00:12:54,190 --> 00:12:56,170 OK, so this is the condition of the third step. 235 00:12:56,500 --> 00:12:57,860 So what is the fourth step? 236 00:12:58,450 --> 00:13:01,570 So in the fourth step, we will make use of these variables. 237 00:13:01,880 --> 00:13:02,610 So I will check. 238 00:13:02,920 --> 00:13:03,700 So has zero. 239 00:13:03,700 --> 00:13:05,760 First row is containing a variable too. 240 00:13:06,220 --> 00:13:12,850 Since it is containing a variable through what I will do, I will trade over the first row and I will 241 00:13:12,850 --> 00:13:14,570 make every element zero. 242 00:13:14,820 --> 00:13:17,320 OK, I will make every element zero. 243 00:13:17,350 --> 00:13:18,310 So if true. 244 00:13:19,370 --> 00:13:21,170 Then make every element zero. 245 00:13:24,220 --> 00:13:27,770 So it will become zero and they are zero already. 246 00:13:27,850 --> 00:13:32,980 OK, now basically, as know, first of all, so this is containing false. 247 00:13:33,160 --> 00:13:35,410 So I will not do anything with the first column. 248 00:13:35,500 --> 00:13:37,700 OK, I will not do anything with the first column. 249 00:13:37,960 --> 00:13:39,640 So basically, this is my output. 250 00:13:40,330 --> 00:13:45,800 Some output is basically zero zero zero zero zero zero three zero zero. 251 00:13:45,820 --> 00:13:47,950 OK, so this is my output. 252 00:13:50,490 --> 00:13:56,950 OK, let us verify whether our solution is correct or wrong, OK, let us verify so our input. 253 00:13:56,970 --> 00:14:05,100 So this was basically one zero one one three four five zero and one. 254 00:14:05,320 --> 00:14:07,170 OK, so this was our input. 255 00:14:07,800 --> 00:14:12,820 Now, this element, does it also make this entire column zero, make this entire rosillo? 256 00:14:12,840 --> 00:14:13,730 So this is zero. 257 00:14:14,130 --> 00:14:17,950 So make this entire column zero and make this and dial zero. 258 00:14:18,150 --> 00:14:20,890 So basically everything will be zero except elementary. 259 00:14:20,940 --> 00:14:26,430 OK, so that means our solution is right now, what is the time and the space complexity of the solution? 260 00:14:27,210 --> 00:14:32,200 So basically the space complexities or the rough one, we are just creating these two variables. 261 00:14:32,220 --> 00:14:37,200 OK, and the time, complexity, what we are doing, we are simply we are trading over the matrix. 262 00:14:37,200 --> 00:14:38,550 So the time complexities. 263 00:14:39,030 --> 00:14:44,880 OK, so now after understanding the logic now let us write the code. 264 00:14:44,910 --> 00:14:50,610 OK, so before writing the code, the efficient approach is basically it's nothing. 265 00:14:50,610 --> 00:14:54,060 It is just making the use of first rule and first column. 266 00:14:54,420 --> 00:14:59,580 Since we are making the use first and first column, I have to store whether the first row first column 267 00:14:59,580 --> 00:15:00,840 is containing zero or not. 268 00:15:00,990 --> 00:15:06,840 If they are containing zero, then our last step will be making the entire row or making the entire 269 00:15:06,840 --> 00:15:08,280 column or both zero. 270 00:15:08,460 --> 00:15:13,920 OK, I am repeating myself, since we are making the use of FirstRand first column, our first step 271 00:15:13,920 --> 00:15:19,400 was to verify whether the first row or first column is containing Azura element or not. 272 00:15:19,680 --> 00:15:26,820 And after doing this second and third step, our fourth step is basically making the first row or the 273 00:15:26,820 --> 00:15:27,420 first column. 274 00:15:27,720 --> 00:15:33,030 If the values are true and this is very simple, start dating from the next one, comma one. 275 00:15:33,330 --> 00:15:38,310 If there is an element, if there is a zero element, we are storing the zero element with the help 276 00:15:38,310 --> 00:15:40,480 of these two in the first round, first column. 277 00:15:40,500 --> 00:15:44,280 Then again, start reading from the next one, comma, one for every element. 278 00:15:44,610 --> 00:15:45,420 For every element. 279 00:15:45,450 --> 00:15:51,150 So if the topmost element is zero, make it make the element, the leftmost element is zero, then also 280 00:15:51,150 --> 00:15:52,650 make the element zero. 281 00:15:53,050 --> 00:15:54,870 OK, so now let's write the code. 282 00:15:55,590 --> 00:15:57,080 So writing code is very simple. 283 00:15:58,410 --> 00:15:59,010 So. 284 00:16:00,750 --> 00:16:04,500 Sorry, let us find out how many rules are there. 285 00:16:04,530 --> 00:16:06,490 So rule number. 286 00:16:07,410 --> 00:16:09,300 OK, so let's make it small. 287 00:16:09,300 --> 00:16:10,610 So random, random. 288 00:16:10,630 --> 00:16:14,130 OK, so this is basically matics nazis'. 289 00:16:16,890 --> 00:16:21,610 And now let us so if the wrong number is basically zero, then do not have to do anything. 290 00:16:21,870 --> 00:16:27,270 So if we can see that it is void and the Matrix is passed by reference, so we have to do changes in 291 00:16:27,270 --> 00:16:30,450 the Matrix only, OK, we do not have to create another matrix. 292 00:16:31,360 --> 00:16:32,190 So basically. 293 00:16:33,550 --> 00:16:40,340 So basically, if the if there are 00, if they are not all, basically, then you can simply return. 294 00:16:41,230 --> 00:16:44,290 OK, now let us also find the numbers. 295 00:16:44,290 --> 00:16:45,400 How many are there? 296 00:16:46,120 --> 00:16:47,720 So for doing this, but again. 297 00:16:47,740 --> 00:16:51,670 Right, this is nothing but mattocks of zero nazis'. 298 00:16:54,640 --> 00:16:59,170 Again, you can write if there are no columns, you get written. 299 00:17:03,370 --> 00:17:08,619 Now, our first step was to contain, if you're going to see our first step was to create two variables, 300 00:17:08,630 --> 00:17:10,329 OK, two boolean variables. 301 00:17:13,349 --> 00:17:14,849 So has 040. 302 00:17:16,300 --> 00:17:19,060 And similarly, so this is false initially. 303 00:17:23,990 --> 00:17:26,210 And similarly, our second element. 304 00:17:27,260 --> 00:17:31,730 Second boolean variable, so this is has zero first column. 305 00:17:34,020 --> 00:17:36,930 Now, let us celebrate the values of these two. 306 00:17:36,960 --> 00:17:41,110 OK, so first let us check for the first row. 307 00:17:41,240 --> 00:17:42,450 OK, so. 308 00:17:45,150 --> 00:17:47,610 Those first rule contains a zero. 309 00:17:49,660 --> 00:17:52,000 OK, now let's check. 310 00:17:52,630 --> 00:17:56,320 So therefore, we have to iterate over the columns, OK? 311 00:17:59,360 --> 00:18:00,170 So if. 312 00:18:03,560 --> 00:18:06,410 So if the first row and the column. 313 00:18:07,580 --> 00:18:09,380 As containing the element zettl. 314 00:18:10,390 --> 00:18:14,170 Then why do you have to do so, we have to update the value of this variable. 315 00:18:15,930 --> 00:18:17,190 We will make it through. 316 00:18:18,430 --> 00:18:20,270 And let's break the loop. 317 00:18:20,290 --> 00:18:25,180 OK, now let us do the same thing for the first column. 318 00:18:25,370 --> 00:18:27,760 OK, let's copy the so-called. 319 00:18:33,240 --> 00:18:37,670 So this is column basically, so this first column contains a zero element. 320 00:18:38,070 --> 00:18:41,910 OK, now this time we will read over the raw number. 321 00:18:42,810 --> 00:18:44,820 We will add it over the rules, OK? 322 00:18:45,120 --> 00:18:51,780 And this will be G and this will be basically zero, OK, and. 323 00:18:54,780 --> 00:18:57,390 This will be basically has zero first column. 324 00:18:57,750 --> 00:18:58,110 OK. 325 00:19:01,340 --> 00:19:07,280 Now, let's move ahead, so what we have to do, we have to find truth and we have to store that information 326 00:19:07,610 --> 00:19:09,470 in the first row, the first column. 327 00:19:09,500 --> 00:19:16,370 OK, so now it's time to make the use of so we will make use of first rule and column. 328 00:19:16,400 --> 00:19:20,240 OK, so for doing this, what will do so for doing this. 329 00:19:20,240 --> 00:19:20,810 What will do. 330 00:19:20,930 --> 00:19:27,500 We will find zero element and after finding the zero element we will store the raw number and the column 331 00:19:27,500 --> 00:19:33,290 number and we will store data on the continent where we will store the information and first row and 332 00:19:33,290 --> 00:19:35,250 column OK and first row and column. 333 00:19:36,050 --> 00:19:42,470 So now let's as I did and remember, we have to start iterating from index one, OK, from index one. 334 00:19:43,910 --> 00:19:45,380 So now let us say trade. 335 00:19:49,120 --> 00:19:51,100 OK, we have to start from one. 336 00:19:56,750 --> 00:20:01,300 Nor do we have to check whether this current element is a zero element or not. 337 00:20:02,030 --> 00:20:08,980 So if metrics is basically if this element is a zero element, then we have to store the information, 338 00:20:09,020 --> 00:20:11,600 OK, in the first row and first column. 339 00:20:12,290 --> 00:20:22,410 So matrix of I zero is basically zero and similarly matrix of zero and G is basically zero. 340 00:20:22,430 --> 00:20:24,710 OK, topmost leftmost you can see here. 341 00:20:25,010 --> 00:20:32,930 OK, so if a current element is zero, what we are doing, make the top Muslimin zero, make the leftmost 342 00:20:32,930 --> 00:20:33,540 element zero. 343 00:20:33,920 --> 00:20:37,250 OK, we are doing this step and now we will do this step. 344 00:20:37,280 --> 00:20:42,790 OK, we will start trading from one component and for every element we will check if the top element 345 00:20:42,840 --> 00:20:45,720 zero make the element zero with the leftmost element. 346 00:20:45,750 --> 00:20:47,060 Zero zero. 347 00:20:47,300 --> 00:20:47,630 OK. 348 00:20:50,170 --> 00:20:53,010 So the court will be again, we have to do the same thing. 349 00:20:56,820 --> 00:21:00,660 It will start at trade from common now for every element. 350 00:21:00,720 --> 00:21:03,090 OK, we have to check for every element. 351 00:21:08,000 --> 00:21:13,340 Now, for every element we have to check, so what we have to check, we have to check the topmost element 352 00:21:13,340 --> 00:21:14,460 and the leftmost element. 353 00:21:14,930 --> 00:21:20,780 So if metrics of, let's say leftmost, so this will be basically zero, M.G.. 354 00:21:23,570 --> 00:21:24,830 So if this is zero. 355 00:21:26,260 --> 00:21:26,740 Or. 356 00:21:30,350 --> 00:21:38,240 The topmost element, so that will be zero energy, OK, zero zero and Jayate column. 357 00:21:41,390 --> 00:21:44,880 If this is zero, then we have to make the element zero. 358 00:21:44,900 --> 00:21:50,680 So basically take a selfie and it's is basically zero now. 359 00:21:51,050 --> 00:21:51,830 Fourth step. 360 00:21:53,320 --> 00:22:00,610 So what is the fourth step forward step is basically if has zero first or has the first column is containing 361 00:22:00,610 --> 00:22:04,380 a brewery will then make every element in that brewer column zero. 362 00:22:04,730 --> 00:22:05,140 OK. 363 00:22:08,540 --> 00:22:11,210 So set the rules for first rule. 364 00:22:13,750 --> 00:22:14,800 OK, so if. 365 00:22:17,530 --> 00:22:19,270 Letters copied the name of the variable. 366 00:22:24,110 --> 00:22:31,670 So if this very well is true, that means the first race containing Azura element initially, so we 367 00:22:31,670 --> 00:22:33,420 will make the NBA Rosero. 368 00:22:33,540 --> 00:22:35,720 OK, so we're making the entire Rosero. 369 00:22:35,720 --> 00:22:37,280 We have to get rid of the columns. 370 00:22:41,110 --> 00:22:46,990 OK, we are making the first roseto and for making the first Rosero, we have to hydrate already. 371 00:22:47,930 --> 00:22:50,020 No, we have to read over the columns. 372 00:22:51,420 --> 00:22:55,500 And similarly, the same situation with the first column. 373 00:22:56,470 --> 00:22:59,190 So set the rules for first column. 374 00:23:00,620 --> 00:23:04,550 And let's change the name of the variable, so this is a zero first column. 375 00:23:05,940 --> 00:23:07,350 So has your first column. 376 00:23:08,540 --> 00:23:13,990 So what we have to do for setting the first column zeros, we have to rotate over their own numbers, 377 00:23:14,000 --> 00:23:15,360 we have to trade over the rules. 378 00:23:15,460 --> 00:23:17,900 OK, so this will be rule number. 379 00:23:19,330 --> 00:23:21,350 So whether or no. 380 00:23:21,370 --> 00:23:23,410 And the number is zero. 381 00:23:23,980 --> 00:23:26,730 OK, so I think we did everything fine. 382 00:23:27,340 --> 00:23:29,410 Let's send our code and then we will submit. 383 00:23:34,270 --> 00:23:36,340 OK, so what we did wrong. 384 00:23:40,910 --> 00:23:42,980 OK, so everything seems fine. 385 00:23:53,080 --> 00:23:58,270 OK, so I forgot to change the condition here, so this will be basically a. 386 00:23:59,380 --> 00:24:00,670 And this will be zero. 387 00:24:00,700 --> 00:24:02,670 OK, so this was wrong. 388 00:24:04,450 --> 00:24:09,190 OK, so we have to check basically the leftmost and the topmost, so. 389 00:24:10,320 --> 00:24:12,090 I think now this is fine. 390 00:24:16,710 --> 00:24:18,000 OK, so now to some. 391 00:24:21,600 --> 00:24:23,910 OK, so our coders are working fine. 392 00:24:25,670 --> 00:24:28,320 OK, so let us take one more example. 393 00:24:29,000 --> 00:24:31,530 So the main aim, OK. 394 00:24:31,580 --> 00:24:37,840 So the main idea, the basic idea behind solving this question is basically make use of first column. 395 00:24:37,880 --> 00:24:43,910 OK, we have to make the use of first rule and first column for storing the information about the zero 396 00:24:43,910 --> 00:24:44,970 element in the Matrix. 397 00:24:45,920 --> 00:24:50,900 OK, and since we are storing the information in the first round first column, we have to maintain 398 00:24:50,900 --> 00:24:51,620 two variables. 399 00:24:51,630 --> 00:24:56,900 We have to first check whether the first choice containing any Element Zero or the first column is containing 400 00:24:56,900 --> 00:24:57,650 element zero. 401 00:24:57,890 --> 00:24:59,960 OK, let us take one more example. 402 00:25:00,260 --> 00:25:09,350 So let's say one two three four zero five to seven three four zero two one four five seven nine two 403 00:25:09,350 --> 00:25:10,210 one three. 404 00:25:10,250 --> 00:25:14,210 And let's take let's make zero here and let's say seven. 405 00:25:14,390 --> 00:25:19,160 OK, so what we have to do is step one, take two variables has zero. 406 00:25:19,160 --> 00:25:20,710 First row has zero. 407 00:25:20,720 --> 00:25:21,380 First column. 408 00:25:21,380 --> 00:25:23,150 Initially, they both are false. 409 00:25:23,840 --> 00:25:27,380 OK, since the first row is containing a variable as irrelevant. 410 00:25:27,410 --> 00:25:29,860 So this will become true. 411 00:25:29,870 --> 00:25:32,270 And the first column is not containing and is irrelevant. 412 00:25:32,280 --> 00:25:33,380 So it will remain false. 413 00:25:34,040 --> 00:25:38,060 Now the second step starting from here, we will go right. 414 00:25:38,060 --> 00:25:39,430 And we will go down OK. 415 00:25:39,740 --> 00:25:40,670 This element is zero. 416 00:25:40,850 --> 00:25:43,580 So make this element zero and make this element zero. 417 00:25:43,590 --> 00:25:47,180 So two one four five four zero since I have zero here. 418 00:25:47,390 --> 00:25:48,680 Make this element zero. 419 00:25:48,920 --> 00:25:52,610 Make this element zero nine two one three seven. 420 00:25:53,030 --> 00:25:53,810 Do not do anything. 421 00:25:54,710 --> 00:25:57,110 Step three again, we will read. 422 00:25:57,230 --> 00:25:59,300 OK, we will iterate from the next one. 423 00:25:59,300 --> 00:25:59,960 Go, go. 424 00:25:59,960 --> 00:26:00,240 Right. 425 00:26:00,320 --> 00:26:04,210 OK, so this element is three Jacoby leftmost so this is zero. 426 00:26:04,400 --> 00:26:05,770 So I will write zero here. 427 00:26:06,020 --> 00:26:17,230 This is zero four two four one zero zero zero eight zero zero four zero zero zero. 428 00:26:17,510 --> 00:26:20,420 So this will be zero and the topmost element is zero for nine. 429 00:26:20,430 --> 00:26:22,730 So make it zero four two. 430 00:26:23,060 --> 00:26:28,700 Leftmost element is seven, but most elements do not do anything for one leftmost element, the seven. 431 00:26:28,700 --> 00:26:31,220 But the topmost element is it also will make zero. 432 00:26:31,220 --> 00:26:32,960 Here again, this is zero. 433 00:26:33,230 --> 00:26:34,790 So I will make zero here again. 434 00:26:34,790 --> 00:26:35,360 This is zero. 435 00:26:35,360 --> 00:26:36,650 So I will make a zero here. 436 00:26:37,100 --> 00:26:41,880 OK, so after step three, what is the condition of the array? 437 00:26:41,900 --> 00:26:46,580 So this is basically when I have two, I have zero zero zero. 438 00:26:47,240 --> 00:26:48,260 I have a zero here. 439 00:26:48,260 --> 00:26:49,550 I have zero here. 440 00:26:49,700 --> 00:26:59,060 I have seven here I have zero zero zero zero zero zero zero zero zero zero two zero zero zero. 441 00:26:59,390 --> 00:27:03,380 OK, so now it's time for a step for a first step for what we have to do. 442 00:27:03,770 --> 00:27:07,060 We have to make the first zero because it contains truth. 443 00:27:07,220 --> 00:27:09,020 So we have to make the first row zero. 444 00:27:09,290 --> 00:27:11,570 So I will write zero here and I will write zero here. 445 00:27:11,570 --> 00:27:12,800 And this is my answer. 446 00:27:14,610 --> 00:27:15,810 This is our answer. 447 00:27:16,650 --> 00:27:20,190 OK, only these two elements will ruin, everything will become zero. 448 00:27:21,260 --> 00:27:25,010 OK, everything will become zero except these two elements. 449 00:27:25,430 --> 00:27:27,620 OK, so I'm a beating myself. 450 00:27:27,650 --> 00:27:29,770 What is the time and the space complexity? 451 00:27:29,780 --> 00:27:33,980 So time is basically we are just writing our diary and space complex. 452 00:27:33,980 --> 00:27:34,880 It is our draft one. 453 00:27:35,160 --> 00:27:38,530 OK, so if you have any doubt in this question, you can ask me. 454 00:27:38,540 --> 00:27:39,200 OK, thank you.