WEBVTT

00:00.620 --> 00:02.180
Hello all and welcome back.

00:02.180 --> 00:07.760
So in this video I would like to now talk about the process to solve a particular problem.

00:07.940 --> 00:13.910
Now as you will move forward in this particular course, you will find that we have created so many

00:13.910 --> 00:16.610
problems which you have to try out yourself.

00:16.640 --> 00:22.520
There are more than 100 plus coding exercises in which you have to write the code and solve a particular

00:22.520 --> 00:23.270
problem.

00:23.330 --> 00:29.090
Those have been very meticulously designed to make sure that you are able to revise each and every of

00:29.090 --> 00:29.990
your concept.

00:30.260 --> 00:36.110
Now, before you jump onto any coding exercise, I want to make sure that you understand what exactly

00:36.110 --> 00:42.740
is going to be the process to solve a particular problem, because the same is very helpful in writing

00:42.740 --> 00:43.460
the code.

00:43.910 --> 00:50.450
Plus, when you will be giving any interview, this is something which you have to always remember so

00:50.450 --> 00:55.190
that you are able to communicate the proper thought process to your interviewer.

00:55.220 --> 00:58.880
To showcase that you are able to think on all directions.

00:58.880 --> 01:02.240
When you are going to solve any particular problem.

01:02.510 --> 01:05.210
Now this advice is coming from a lot of experience.

01:05.210 --> 01:12.680
So I have been taking so many interviews, like I have actually conducted more than 100 plus interviews

01:12.680 --> 01:17.660
professionally, then have given so many interviews in major companies startups.

01:18.470 --> 01:23.360
Along with that, I of course am a mentor at different different platforms where I weekly interact with

01:23.360 --> 01:28.550
many students for taking their mock interview to understand what problem they are facing, and also

01:28.550 --> 01:31.400
to see why they failed in the interview which they have given.

01:31.490 --> 01:35.870
So this is going to be a lot important, so please make sure that you follow it properly.

01:35.900 --> 01:37.580
Okay, great.

01:37.580 --> 01:42.410
So now let us start everyone and see that if we are given a problem, what we have to do.

01:42.740 --> 01:48.980
The biggest mistake which most students do is that they directly jump into writing the code.

01:49.160 --> 01:51.200
And that is something which we should never do.

01:51.230 --> 01:57.830
Okay, so the very first thing is to always analyze our problem.

01:57.860 --> 01:58.550
Okay.

01:58.700 --> 02:03.040
So the very first thing is to analyze our problem.

02:04.210 --> 02:09.670
Now, what do I mean when I say that we have to analyze the problem which we are given?

02:09.760 --> 02:18.400
We have to see that what is the input we are given and what is the output which we have to.

02:20.410 --> 02:22.420
Print or return okay.

02:22.960 --> 02:29.620
Along with that, moving forward, you will understand that how we can also handle the constraints which

02:29.620 --> 02:30.910
are provided in our problem.

02:30.910 --> 02:31.870
So many problems.

02:31.870 --> 02:33.640
They have constraint on some variables right.

02:33.670 --> 02:38.110
The input size, the time or any particular variable.

02:38.110 --> 02:39.490
It has some constraint.

02:39.520 --> 02:45.610
All these are the things which we have to initially make sure that we are analyzing before jumping to

02:45.640 --> 02:46.690
write the solution.

02:46.990 --> 02:49.930
Second, we should make sure.

02:49.960 --> 02:54.880
Now again, before writing or jumping to the code, we should break down our problem.

02:57.670 --> 02:59.290
Break down problem.

03:03.070 --> 03:05.080
Into smaller sub parts.

03:09.850 --> 03:12.490
Now this is the reason we learned about flowchart and everything.

03:12.490 --> 03:16.300
The pseudocode many things will be there which is going to be very straightforward.

03:16.330 --> 03:17.620
You don't have to do anything.

03:17.620 --> 03:19.090
You can just take in the input.

03:19.090 --> 03:19.840
You have the input.

03:19.870 --> 03:22.930
Now you can maybe go through your list.

03:22.960 --> 03:24.040
Everything is fine.

03:24.040 --> 03:30.640
But we have to make sure that if any particular complex part is there and problem as a whole should

03:30.640 --> 03:34.750
be breaking down into the overall smallest subproblem.

03:34.750 --> 03:41.650
The reason is that as of now, also, we have a vague idea that what we have to do if we try to write

03:41.650 --> 03:46.180
the code right now, then it's surely going to happen that we are going to induce many errors into our

03:46.180 --> 03:46.690
code.

03:46.690 --> 03:50.350
And then we have to spend a lot of time debugging, right?

03:50.350 --> 03:53.110
It is always said to think twice and code once.

03:53.110 --> 03:55.300
So this is from where this philosophy is coming.

03:55.480 --> 03:56.380
Third.

03:59.370 --> 04:00.480
Remember.

04:02.700 --> 04:04.770
Or enlist.

04:06.960 --> 04:09.300
The concept.

04:10.410 --> 04:12.330
Now again, this is coming from an experience.

04:12.330 --> 04:14.820
Let's say the problem is given for a list.

04:14.820 --> 04:19.020
Or it contains a dictionary, or it contains, let's say a set okay.

04:19.050 --> 04:22.920
So what are the different things which you are aware about that particular things?

04:23.160 --> 04:27.000
Quickly remember that in your mind we know that set doesn't allow duplicates.

04:27.030 --> 04:29.550
Dictionary keys and values are stored.

04:29.730 --> 04:36.210
List can store anything, whereas a tuple is something which is something not cannot be extended.

04:36.240 --> 04:36.840
Right.

04:36.840 --> 04:42.210
So all these things, all these understanding, you should remember depending on what is given to you

04:42.210 --> 04:43.230
in your question.

04:44.010 --> 04:50.100
Next part is take 2 to 3 examples.

04:51.300 --> 04:59.040
Normally what happens is that the example is given okay in a problem which is like asked to you be solved.

04:59.160 --> 05:00.090
Interviewer.

05:00.120 --> 05:04.770
Also, if he will be giving you any particular problem, ask him for some examples.

05:04.800 --> 05:05.490
Okay.

05:05.520 --> 05:10.410
If he has not given that, if he has just given a single example, ask him for another one to clear

05:10.410 --> 05:16.650
out your understanding that what you are thinking is exactly what the problem is asking as well.

05:16.680 --> 05:26.250
So take 2 or 3 examples, and the major reason for that is to clear out confusion or gap.

05:26.280 --> 05:27.630
Again, this is very, very important.

05:27.660 --> 05:34.290
Many students I have seen that they are just assume many things and that is where they miss out on a

05:34.290 --> 05:35.370
lot of opportunities.

05:35.400 --> 05:35.610
Okay.

05:35.640 --> 05:37.440
So this is not something which you have to do.

05:37.470 --> 05:39.630
If I personally take any interview.

05:39.660 --> 05:42.060
Something which I have done in companies.

05:42.150 --> 05:47.760
If I give a problem and the student doesn't ask for any example, that's a huge red flag for me.

05:47.790 --> 05:51.720
Even if the problem is as straightforward as finding the maximum in a list.

05:51.750 --> 05:53.550
Okay, great.

05:53.580 --> 05:54.720
So let us move forward.

05:54.720 --> 06:00.140
Then once this is done, then we can think of the problem of the solution.

06:00.140 --> 06:02.390
And now we can write.

06:05.330 --> 06:06.620
A pseudo code.

06:10.730 --> 06:13.550
On a paper or a scratch code.

06:13.550 --> 06:14.360
On a paper.

06:14.540 --> 06:17.750
Now, I am a huge proponent of writing the pseudo code.

06:17.780 --> 06:23.330
Code, or at least the basic idea of something complex on a paper, because that is a lot helpful,

06:23.360 --> 06:23.600
right?

06:23.630 --> 06:26.540
I am not asking you to write the full code with all the syntax and everything.

06:26.540 --> 06:28.250
No, just the basic code.

06:28.280 --> 06:28.520
Okay.

06:28.550 --> 06:36.680
So instead of writing the full for loop, maybe you can say that for I to n okay, something like this.

06:36.680 --> 06:39.500
But you should have an idea that okay, what exactly you want to do.

06:39.560 --> 06:42.200
This is something which is required initially a lot.

06:42.200 --> 06:47.510
But as you move forward, once you have solved 100 problems, then it will become automatically and

06:47.510 --> 06:50.270
you will just be writing the complex, logical part.

06:50.450 --> 06:53.060
Okay, can we now jump to our solution?

06:53.090 --> 06:54.410
Well, not as of now as well.

06:54.440 --> 06:58.820
Now what I want you to do, everyone sixth is to dry run it once.

06:58.850 --> 07:05.030
Okay, so what I mean by dry run, you will be seeing me doing this a lot in your future problems.

07:05.030 --> 07:10.730
But dry running basically means that whatever logic or solution you have written, whatever examples

07:10.730 --> 07:16.760
you have chosen, just try to run it through those, run those examples through the solution or the

07:16.760 --> 07:21.230
pseudocode to understand if it is happening exactly the way you would like.

07:21.260 --> 07:27.350
Okay, there are something which you have not assumed, okay, that thing is going to help catch more

07:27.560 --> 07:30.740
errors or bugs in our code or in our understanding.

07:30.740 --> 07:36.470
So run it once, then the next one is going to be.

07:36.680 --> 07:38.990
Finally, write down your code, okay?

07:38.990 --> 07:40.340
Write down your solution.

07:41.750 --> 07:46.040
Once you write down the solution at this step, you will see that your overall solution is going to

07:46.040 --> 07:46.670
have less.

07:46.700 --> 07:54.290
Lots of less errors like it will have so many less errors than what you it could have been if you would

07:54.320 --> 07:55.940
have directly start to write the code.

07:55.940 --> 07:59.300
So it's going to be a lot bug free, right?

07:59.330 --> 08:03.980
It is not that you will be inducing some errors here, because you have focused on lots of things in

08:03.980 --> 08:05.720
the first 4 or 5 steps.

08:05.750 --> 08:10.010
Now again, these are not the steps which you have to write down and do before each problem.

08:10.010 --> 08:13.010
Initially for the first 2025 problem.

08:13.040 --> 08:14.990
Be very focused on these things.

08:14.990 --> 08:16.250
As you move forward.

08:16.250 --> 08:20.990
They will start happening, uh, internally without your proper thought.

08:20.990 --> 08:23.900
So you will just get habitual to all these steps.

08:24.530 --> 08:27.320
Then there is a last one, which is again very important.

08:27.320 --> 08:29.000
And I will write it in green.

08:29.540 --> 08:31.910
And this again is coming from an experience.

08:31.940 --> 08:35.240
Look out for.

08:37.460 --> 08:38.810
Edge cases.

08:41.720 --> 08:44.000
Or boundary condition.

08:46.280 --> 08:50.060
If you are asked to get the length of an array okay.

08:50.090 --> 08:51.110
Or a list.

08:51.140 --> 08:52.700
What if the list is empty?

08:53.780 --> 08:58.990
What will you do if you have to get the last or the first number in a list.

08:59.020 --> 08:59.650
Okay.

08:59.680 --> 09:07.030
All these are the boundary or the edge condition on which majorly we see our code failing in the overall

09:07.030 --> 09:07.510
course.

09:07.510 --> 09:11.560
I will also be keep on reminding you that this is some edge case.

09:11.560 --> 09:15.490
This is some boundary case which we have to handle because they are very important.

09:15.490 --> 09:19.900
They are actually the reason your code is going to fail even after thinking about each and everything.

09:20.320 --> 09:25.750
And once you have now followed this process each and every step, I can assure you that your code is

09:25.750 --> 09:29.710
going to be proper without any error and it is going to run as well.

09:29.740 --> 09:30.370
Okay, everyone.

09:30.370 --> 09:36.220
So this is the proper overall structure which you should follow to solve your problem.

09:36.430 --> 09:39.820
These steps are something which I have created based on my experience okay.

09:39.850 --> 09:41.770
Not like you will find them somewhere.

09:41.800 --> 09:46.600
The boundary condition, edge cases, the dry running it once, then writing the pseudo code on a paper

09:46.600 --> 09:49.870
as opposed to people suggesting that don't write anything on paper.

09:49.870 --> 09:53.290
No, you should write the pseudo code on a paper or on the IDE as well.

09:53.320 --> 09:58.800
Okay, just like in the last class, we saw how we wrote this kind of a pseudo Pseudocode, right?

09:58.860 --> 10:04.890
The same will also get you into a habit that tomorrow, if you are giving an interview, you are able

10:04.890 --> 10:09.540
to first communicate with your interviewer that hey, this is the approach I'm working on, right?

10:09.570 --> 10:11.370
So that is again very, very important.

10:11.400 --> 10:14.310
Directly jumping into the solution will not take you anywhere.

10:14.340 --> 10:16.950
We have to make sure to write the solution.

10:17.670 --> 10:20.190
It is not that we have to quickly write it.

10:20.190 --> 10:23.190
If you are not understood things, then it's going to be a problem anyway.

10:23.220 --> 10:27.960
Once you follow this overall process, you are going to write the solution quickly.

10:27.960 --> 10:34.020
Then someone who does not do it, and I can assure you, after 5070 problems it is going to be natural.

10:34.020 --> 10:38.580
You don't have to actually worry about them and internally you will be doing each and every of those

10:38.580 --> 10:39.210
steps.

10:39.240 --> 10:41.280
Okay, so cool everyone.

10:41.370 --> 10:44.280
Moving forward, I will also be solving some questions for you.

10:44.310 --> 10:49.890
You will have lots of coding exercise, so please make sure that you are following this framework and

10:49.890 --> 10:55.650
you will see a change in the way your code gets passed or overall in your coding journey.

10:55.680 --> 10:58.710
Okay, so great everyone, let's meet in the next video.
