Hey, guys, what's up?
So today I saw one more interesting problem on Eddys.
So the problem is find the largest in L.A..
For example, suppose the number of elements in an ad is Ford and the elements are four to one.
And then.
So what is the largest element then?
So what should be my output?
My output should be the largest.
It was 10.
So we have to find the largest element in league.
Eddie, suppose the number of elements are.
Five and the elements are, let's say, seven,
seven, two, four, one and nine.
So virtually my output, Marbut should be nine because nine is the largest element.
OK.
So is the problem clear that we have to find the largest element in the Eddie?
So what we have to do first.
First of all, water they can put.
So CNN and a number of elements, then I will either do at it and I will take and put seen a fight now
and put is ready.
So first of all, we will do it.
And and then a number of elements.
Now big elements as input.
So it goes to zero my list and then I bless bliss.
See in a fight.
Now at this point of time our Ed it will be ready.
Now what we have to do, we have to find the largest element.
So we are finding the largest element.
What do you suppose that is, let's say and equals four number of elements out of food and values out.
Five, one, nine and two.
So these are my values.
So the idea is very simple.
What I want to do, I will take a variable largest.
I will decorate it the largest.
And I really only slice it with minimum.
OK.
So I will take a variable.
Largest and largest is initially into minimum and minimum.
You can say minus infinity.
OK.
For understanding you can say the minimum is minus infinity.
I have a very largest which is initialised or two minus infinity.
Now, what I will do, I will.
I agree or disagree.
So I will take Ovadia, will I?
And I will.
I did.
So each time what I will do, I will compare the current value with the largest.
So if.
The current value.
That is if fight the current value.
If a fight is greater than my largest value.
If a towfigh is good, then my largest value, then I will update my largest value.
So logistic was a fight.
OK, so this will be our logic.
If the current value.
If the current value is good, then our largest value, then we will update our largest value.
And that is the reason I initialized my largest with minus infinity so that the first value will be
greater than the largest value and largest get updated.
OK.
So how it will work?
So first of all, I will compare largest with five.
So is five for good.
Then minus infinity.
Yes, the condition is true.
My largest really becoming close to five.
Now I will come here.
Now I will compare.
Is one good then my largest.
You know, the condition is false.
Don't do anything.
Now I will come here.
So I will check.
Is my value greater than my largest value?
Yes, the condition is true.
We will update our largest delusive largest becomes mine.
Then we will come here.
So I will check.
Is too good.
Then my largest.
Really, you know the condition is false.
Don't do anything.
And finally I will print out largest which is containing nine.
OK, so the logic was the logic and problem both had it easy.
So let us test our program.
That's right, our program.
So suppose I named.
Largest.
Largest of any.
Now, what we have to do is, first of all, we will take input.
So end an end to the number of elements.
And now let us take so first of all, it does make an eddy of size and so and a of and just taken so
I equals zero.
I list an end I plus plus scene.
If I now I'd add is ready.
So what we have decided we will take a variable largest which is initially into minimum, it is minus
infinity.
Then what I will do, I will compare this largest value with all the elements and deti so that as I
did or the idea again so indite equal to zero I less than an I plus plus.
So now I will check if the current value is greater than my largest trading.
So if the current value is greater than my largest value, then I will update my largest value.
Two largest equals.
Largest equals if I.
OK.
So if the current value is greater than my largest value then I will update my largest value.
Simple.
And finally, when this lovely terminate, I will have my answer stored in the variable largest Soucy
out largest.
OK, so this is all that we have to do.
So there doesn't know I'm.
So hash included.
Oh, so what?
What we did was we haven't made the final.
Added God to see we have two murdered NCP.
So I'm creating a new file.
Largest.
Of Eddie Dhada CBB.
OK.
So here I find that we have created the extension is Darcy.
Darcy means it is a sequel but in Seek or there isn't a thing called IO stream.
It is, I think S2, DSU, something like that.
OK, so what do you do.
I will copy and paste this whole Cordier.
Now, your distaste I vote on.
So naturally, a number of elements are three and the values are one, two and three.
So to use the largest number you can print here is two out.
See, our largest value equals.
Now let us run it, I mean.
Number of elements, ar3 and elements are one, two and three, so large Australia Post three letter
number of elements are five and the values are three, six to one and four.
So largest value is six.
OK.
No, what if we have to find the smallest element?
So we have to find the smallest element.
So everything will do him.
What I really do.
I didn't make a variable and smallest.
And I will initialize it to intermix.
I will initialize smallest would intermix, which is plus infinity for understanding purpose.
Now I will.
I did what the eddy.
And when I am doing what I will do.
I will check if the current value is good to them.
Sorry if the current value is less than my smallest value.
Then write down.
What I do is I will update my smallest value.
OK.
So logic is very similar.
So.
OK, so let's update discordantly.
So I am taking a small list of any one small list, which is a quiz to Intermix and Angeles, my list
is a quiz took place in Verdie.
Now, I will check if the current value is less than my smallest value.
If the current value is less than my small Australia, what I will do, I will update my small list.
Really.
And similarly, we will print out the
smallest
value equals.
And then so they're distressed at the one.
So in the metaphor, elements out of five and the elements are six to one, five and four.
So the largest Ray Lewis six and the smallest Ray Lewis one.
There's a one more time.
Later in the middle of elements are.
And values are 70.
Twenty five and 10.
So my my district is 70 and my smallest value is 10.
So one change there you can do here is where you can also ride.
So I am initializing my largest value from minus infinity where you can see.
You can also say this.
Suppose my largest value is Defoe's to value of the 80.
We can also write like this.
So what I'm doing here is I am initializing my largest value to the fullest value of DNA.
And if this is the case, then I will start competing from one.
OK.
And if this is the case, I will start competing from one because I am assuming that my foster lose
the smallest value even if he will start competing from zero.
So they will not win a defense because in that case I would start from zero eight four zero will be
compared with the largest and largest as initially IL zero.
So this condition will be false and there will be no there will be no changes.
And similarly, you can also write.
You're so right and
smallest.
I am assuming that my first value is the smallest value in the ATF.
And if this is the case, what I would do, I will start competing funding first, will you?
To a number of elements are five and the elements are when they will tell you four and five, says Mollet.
Now the smallest is one of the largest is five.
They will not be any changes, okay.
They will touch them, even if you will make it zero.
Then I will say they will be no changes.
Our output will be correct.
Little elements are three and elements are two, five and four, so large Israeli is five and the smallest
or lose four.
Okay, so you can visualize it.
Either with the first element of the Eddie or you can initialize it would and the minimum or in the
max you add choise.
OK.
So this is it for this video.
Thank you.