To find the maximum element in an array, initialize a variable with the first element, then iterate through the array updating the variable whenever a larger element is found; to find the minimum element, use the same approach but update when a smaller element is encountered. This fundamental array operation demonstrates the basic pattern of initializing a result variable and comparing each element against it during iteration.
Deep Dive
Prerequisite Knowledge
- No data available.
Where to go next
- No data available.
Deep Dive
DSA Every Day Day 17Added:
We are live. We are live. We are live.
We are live.
We are live.
We are live. We are live. We are live.
Okay guys, welcome to the stream. Let's start.
Just like the street lights lit this time like a fire in a blaze burning down. Can't be afraid to leave this.
We got this far. Don't know how. I see danger in your eyes. Heat. Heat.
Yeah. Heat.
Welcome to the stream, y'all. Welcome to the stream, y'all. Welcome to the stream.
Welcome to the Welcome to today's stream, y'all. Welcome to today's stream.
So, the game plan. So, right now, we have some beginner friendly array problems.
We have some beginner friendly array problems right here and we're going to go through them now depending on where depending on if we are going to be able to go through these array array array problems. If we finish all of the array problems, then we're going to below this there are some strings problems.
So that's the next one we are going to uh the next one we are the next ones we're going to do if we get past the array problems but we will see.
All right shop. So let's start with the first one.
Let's start with the first one.
Okay, let's see the first first one.
Find maximum elements in an array. Okay, find maximum elements in an array. So let's say it's going to be find max with our so vector this is vector this is a dynamic array okay find max in the array and then let's say no actually that's it okay so what are we going to do first we're going to set a sir and sir and by default this is going to be the first element of the array. Okay guys so array of zero if you have if you're a complete beginner to programming and you have not seen arrays before array of zero this means is going to get us the first element in this array. So if the first element is one if the if uh the elements in the array are one and two this is going to give us that this element which is at this is position zero this position one okay so for why are we setting answer to this right now basically what we are going to do we are going to assume that the first element inside of this array is the is the largest element element and then if the first ele if the first if there is any element which is found which is greater than this element we are going to set answer to that element and when we set answer to that element if there is any element greater than answer with than answer than that element in the array which is answer right now we are going to set that element to answer and that's basically how this works So what what do we need to do? We write a for loop. We need to iterate through the array.
Okay.
So this I right here, this is basically going to be the position of an element in the array. So if we see out let's say array of I, we can see that All of the just return need to return answer.
Let's just see this.
Okay, I need an array.
Vector int R is equal to whatever this is.
where this is like this and then find max R.
And now the array should get printed.
Find max for R. What am I missing?
See out of I.
Okay. What?
Okay. Maybe if we see out this get three.
Okay. Let's do it as void about zero.
Let's do it as void.
And let's just do this vector in R. Okay.
Okay. What is happening on that side? I have no clue why this is not answer of zero vector and R find max R. Okay, I have no clue why is this not printing R condition is wrong. Oh, okay. Okay.
Okay. Okay. Okay. I have written and shift operator here. Okay. Okay. Okay.
Okay. So this uh yeah less than okay that's what was wrong. So we can fix this and that is going to give us okay that gives us okay this is how we iterate through an array. we do a for loop and then uh the i is going to match each element inside of the uh it's going to match each element inside of the array. So first I is going to be zero and this is going to give us R of zero which in our case is three then I no it's zero then I is going to be one and this is going to give us array of one which is eight and so on until the last element. now but we do not want to see out the see out the ele we do not want to print the array elements to the console we want to get the maximum elements so what we're going to do if the current element is greater than answer then answer is going to be equal to the current elements so this is going to do basically let's do the following so let's take this array Okay, let's take this and we're going to draw it out in paint like this.
Let's add some commas.
So, we are going to put this. So we're going to say I zero one 2 3 0 1 2 3 4.
Okay, this is this is index slash I this is what this is.
Okay, one two four. So first answer is going to be set to r of zero which this is equal to three is equal to three.
Uh so yeah this is going to be so because as we can see right here the element at index zero is uh three and now basically what happens now so we run a for loop.
So four I so four from I to size of two length of array.
Okay.
And basically on each iteration so on each iteration we check if we check is take if uh the array of i is greater than answer. So basically if is current is element on current iteration greater than the one we already have.
Okay.
So, if yes, if yes, we're going to we're going to if yes, we're going to if yes, then then answer will be equal to array of I which is the current element.
else if it's no.
If it's no, if it's no, we are going to do nothing.
Nothing.
Don't reign answer.
And we're going to continue looping.
Okay.
So, this is basically how this works.
This is basically how this works.
All right.
Okay.
So, um wait a sec. Where was I? Did Okay.
Did I explain everything? So, we first we set R to the first element. Then we move from R to link of A. Is element on current iteration greater than the one we have we already have which is answer which is array of zero. If yes then answer is going to be equal to array of I which is the current element. If no do nothing don't reassign answer when looping. So basically if no element inside of the array is greater than this one then it's going to remain three. So if there's no element in here which is greater than three then the answer is going to remain three or the first element.
Okay.
And that's basically how that works.
Now let me prove that this works by seeing the maximal the maximum element in this array and this should give me 10.
Okay, there we go guys. All right, and that's for that one. Now find minimum element. This is basically kind of the same. I'm even just gonna copy. This is basically copy paste, guys. This is basically copy paste. But we need to change only one literally only one thing. Let's uh name this fine min. We need to change only one thing.
Now what now that uh that I went to the previous explanation what do we need to change? We do not want to get the biggest element. We want to get the smallest element.
So what do we need to change?
Okay.
What do we need to change?
Basically what we need to change is this sign right here. Instead of saying if instead of saying if the current element is greater than answer we have to say if the current element is less than answer.
So what are we doing here? We are assuming that at first that the array of zero the first element is the smallest element. Then we go through all of the elements of the array and if we find an element which is uh smaller than our answer then we set our answer to that element. And since and this will check uh basically for every single element.
If answer is less than that is if answer is greater than that element. So if the element is less than the one we currently have, we update the one we the one that we're going to return as from the function and that happens on every iteration and that is basically that one.
Okay. So here let's say we're going to have a second array and it's going to be with these.
And now I should get find min and we should get we should get one.
Okay. Let's just make sure this is on a new line so we can so it's easier to see to read. Yeah, we get one. Now if we if we pass the original array we're going to get three.
Okay. And that's basically Wait, what? Oh, okay. It's two. So, two is the smallest.
Okay.
All right, guys. All right, guys.
Okay, so that is that one. Let's get the next one. Sum of all elements. Now, pretty sure there is a I think there's a built-in function in C++, but we're not going to we're going to write it from scratch. So, sum we're going to say some array like this with array. We're going to say our total is going to be equal to zero. Then for each element in the array we are going to add that element to our total. So at first total is going to be equal to zero. Then when we add the first element which is three total is going to be equal to one. Now we're on the second iteration. Then the element which we are looking at is eight. So then total is going to be equal to 11 after adding eight to three. Then we're on the third iteration. So this we're at two. Now this will become 13. 3 + 8 + 2 13 or 11 + 2. Now fourth iteration we have 13 + 10. So 23 and final iter final iteration we have uh 23 + 5 28. So we should get 28 as the answer.
28.
Okay. Uh 28 see out total. Oh no, not see out return total. Okay. And now we should get we should get 28 should get 28.
Uh let's see sum of array is going to be just array and this is going to go 28 or it should let's see okay what happened some array total 140 oops uh okay I was talking about 28 and I added 28 to the total we instead said we need to add every element to the total and now we should get 28.
Okay, there we go. 28. Okay, I'm even going to draw this. Okay, I'm going to draw this.
So, let's remove some stuff which we don't need right now. So, where is the eraser? Okay, here it is.
Okay, let's uh make it bigger and even bigger so it's easier to delete. Okay, so this is what we have. This is our array at first total is going to be equal to zero.
And in the first iteration when I is equal to zero.
Okay, then array of i is going to be equal to three. All right, array of i is going to be equal to three. So now we're going to say total equals total total equals plus equals uh array of i which is three which is three and basically what what's is plus equals it's same same as same plus equals plus equals is same as total equal total plus array of i.
Okay, so this uh we basically shorten it a little bit. It's quicker to write it this way, but you can also write it this way as well until you get familiar with this. So right now total is equal to three.
Then then total is equal to two. Then then I is going to be equal to one.
All right.
And then array of I is going to be equal to 8.
Okay.
And now we are going to add eight to the total. So we're going to say total plus equals array of i which is eight.
And now total is going to be total now is going to be 11.
Total equals 11.
And then I'm not going to write the until the end, but that's basically what happens.
That's basically what happens.
Um, that is basically what happens.
So, okay, wait a sec.
Basically, what happens? So, total.
Yeah. right now and then we're going to add two which is going to make total 13.
Then we're going to add 10 which is going to make total 23. Then we're going to add five which is going to make total 28. And then then f final answer is total equal to 28 like that. Okay. Okay guys that one is done and dusted.
That one is done and dusted.
So let's get go to the next one. Count even numbers.
So this is also a very useful one to get a grasp of a few things. As you can see, we have the hints if x module 2 is equal to zero.
All right.
Because every time so this is remainder.
So every time you divide a number x, if you divide it by two, it's going to give a remainder of zero if it's if it's an even number. So even number even numbers are for example 2 4 8 10 16 94. Basically these are even numbers.
When you divide these by two, divide by two equals to no remainder.
But if you divide the if you divide odd numbers like 1 3 17 uh what else? 23 by two is going to be equal to remainder of one.
Okay. And basically so if this is equal if the remainder is equal to zero this is going to be true.
If the remainder is equal to uh one equal to anything else this is going to be false.
Okay. And now let's do up the uh increase your volume. I mean, your voice is very low. Increase the sound output, dude. Uh, this is basic. I don't have a built-in mic. And this is basically the best we can get. So, also when you watch on Google, if you're if you're if you're watching inside of Google Chrome, it's going to be it's going to be quieter, but if you're watching from your phone, then it's going to be louder.
or I'm gonna So right now, man, I cannot change I cannot increase the volume right now.
Uh but I will try to see what I can do with the for the next stream.
This I mean I'm pretty sure this is from my microphone. I don't have a microphone. This is the built-in microphone in my laptop. So maybe that's why. Anyways, let's continue.
So we need to want to count even in vector int r and we're going to have our counter and we're going to want to iterate basically guys for basically for about a lot of these questions you need for basically for all these questions that are at least these you need to know how to iterate through an array. So this is equal to zero. I is less than R do size and I is ++.
Hello. Uh hello hello Gurav. Welcome to the stream. Hello Gurav. Welcome to the stream man. Welcome to the stream. How are you? How are you doing?
Headphones mic will help you. Okay.
Thank you, man. I'll see what I can do.
I'll see but I can't I'll see what I can do. Thanks for the Thanks for the advice.
Uh so right now we want to we want to have a condition. So only if actually there is two ways uh at least what I know to I'm going to show you guys both ways of how to find out if a number is even. So actually let's create another function called uh P is even int n like this.
So the first one is going to be return and this two is equal to zero. And then pull is even two is going to be return return and add and one equals equals zero.
Okay. So this one I'm going to explain in a bit. for now. Let's let's use this one. Now, I don't know how much uh actually how Okay, for everybody who is in the chat right now, tell me how uh how what what how good are you at DSA right now? Have you not done any DSA? Have you solved DSA? Are you decent?
Are you a beginner? Like how far are you inside of your DSA journey?
I would be very interested to know.
Okay, so let's continue. So we have a separate function which checks uh if the number is even.
So we're going to just call if is even and we're going to pass that number which is array of i or the current number which we are iterating through and if it is we're going to increment our counter. Now this in C++ and in JavaScript this is basically counter++. This is the same as saying counter equals counter + one. But it's just a shorter way of doing it. Actually I think this is also it's not just a short of way of doing it. I think it's pretty much there's other there's other reasons why you do it. But uh that's uh I don't if that's the case I wouldn't know. So yeah that's basically that and then we just have to return the counter and that's going to give us the answer. Okay.
First day I have learned Java only.
Hello to official toish.
Totish official. Hello to welcome to the stream man. Level zero. Okay.
So uh yeah.
Okay. Okay. I have learned Java only. I mean uh in Java I'm pretty sure that classm I'm pretty sure that uh in Java that you can also say plus+ uh like this.
Okay. Okay. All right. So uh yeah is even and then we should get the answer. Let's see. Okay. And then I'm going to explain if you guys haven't seen this, I'm gonna try to explain this as best I can as well. So right now, okay, let's comment this out.
Comment this out. And this is going to uh see out count even count even in array.
And this should give us uh one, two, three.
Should give us three before turn. Oops. Okay. I I have Yeah, I use JavaScript a lot, so I messed that up. In JavaScript, you can use three equal signs. And there we go. We get to three. So, okay. Now, let's do is even two.
Let's do is even two.
Call me Parthf. Okay. Nice to meet you, Parf. Nice to meet you, man. Welcome to the stream. Okay. So, uh Okay. So, where was I? All right. Yeah, the is even two. So, this right now, let's add another even number. And this should give me four right now.
Okay, there we get four.
So, what is this? What is this?
So, okay, let's delete all of this first.
Delete all of this and then we're going to look at and and one. Okay. So, what is n? Let's say n is equal to four.
And what it it this end is something known as a bitwise operator.
This is a bitwise or is it? Yeah, bit.
Yeah, this is a bitwise operator. So basically just it's something like and in if statements it's something like and if statements.
So basically this checks if the the last digit of the binary representation of n is equal to is one. If the last digit of if the last digit of the binary representation of n which is 1 0 0 is one then this means that the number is odd. If it's not, it means that the number is even.
So right here since this this is the binary of four of four.
So basically as we can see the last bit in this one is zero. So this is not odd.
But for number like number like five five in binary is 101.
So this is binary of five.
Okay.
Okay. This is binary of five.
And as we can see the last set the last bit. So this is a bit representation of the of uh of the decimal number. And we can see that the last bit here is is uh actually uh one is actually one. So in this case the number we know that the number is odd.
So let me even write this. So basically this is how this looks internally kind of. So basically we have 100 and then here at the bottom we have we have uh 001.
So basically this is what happens kind of under the hood. So every num every integer is can be represent every decimal integer can be represented as a binary for as a binary number.
And so this is basically how the how pro how the programming I think this is how the programming language looks at things internally in uh in in binary numbers.
And what happens here is is the same as when an if statement. So this is think of this is this is the zero is false and one is true. So zero and one both need to be true. So is this true? No. So that's a zero. Then zero and zero. Is that true? No. That's another zero. Then one and zero. Is that true? No. That's a third zero. And in this case uh when we get an even number like four we can see that the result is zero. And that is why right here we if we say let's say four and one this is going to give zero and we are checking if it is equal to zero and if it is then that is why we return that it's even otherwise otherwise Uh when we check for 101 and and 001.
What are we going to get here? Let us see. Let me just move this and then move this as well. What are we going to get here?
Well, first we are going to get so as we can see uh the one and one is one. So we're going to get one like this. Then zero and zero is zero. Then one and zero is also zero. But this is we can see the number which we got from ending five and one is uh is a we actually got a number. So in this case this means that this number uh that this number it the number n or five is an odd number. And that's why when this gives something that is not zero, uh this is going to return false. And basically we're that's how we're going to know that this number is uh not even basically. Okay, I hope uh I hope I kind of managed to explain that. Keep in mind guys I I only right I only the only topics that I kind of know right now in DSA are bitwise money bit bitwise operations. I know also some recursion and that is basically kind of I mean I know how to work with arrays and strings as well kind of keep in mind that I'm not a DSA master yet. So take all of my explanations with a grain of salt. But I'm trying to explain what I know uh what I know as well as I can so it can be useful both for you guys and also from me and also so it can be useful a little bit for you and also a little bit for me because when you explain something that is a very good way to cement your knowledge.
Okay. So all right. So um all right that is that one done and dusted. Okay done and dusted. Next one.
See what is the next one.
Okay so we get that one. Now we have count odd numbers. Now guys basically we can just this is basically I mean I already explained it. This is basically the same question but we just instead of is even we have to say not is even.
Okay. We we can literally just copy paste this entire function we can call this count odd and what we have to do is not boom.
So uh is even is going to return either true or false. When you say not of true that is going to give false. When you say not of false that is going to give true. And that is why this works or it should work. It should work. Okay. So let's uh Okay. So let's just see out count and R. Let's see. It should be one two should be two. I misspelled R.
misspelled that. Let's run again. Okay, there we go. Two. All right. So, that is basically that one done and dusted as well. Uh yeah, I don't think I need to I mean this is B. I already explained how the even and odd works.
So, yeah, I think that is okay to move on right now.
Okay. So, next one. And if you guys have questions, I will try my best to explain.
I will try my best. Okay, so next one is find how many times a number appears.
Okay, this one is also not hard.
So, uh let's get to it. So, we have a target.
Okay.
So, let's do int like this. And we're going to say count n appear or something.
And this is we're going to have our array and we're going to have the target.
Going to have a target.
Okay, let's say count target here since this is going to be called targets and we just need to say counter.
We need to loop through the array and we need to say array do size like this and then we need to increment.
So basically if the the current element is going to be equal to target, we need to just increment the counter and then we're going to return it.
We're going to return it.
Return a counter. So what is what is gonna So why does this work? Well, this works because of this condition. If we if the current element in the array is equal to the element that that we want to count, this is going this counter is going to increment and if not it's just going to move on to the next element and that and that is going to happen until the end of the array.
Okay.
So that is basically Okay. Now let's see out the count target up here and then let's say R and then we want uh let's say want three. This should give me one also.
Let's comment these out. So I should get one right here.
Okay. Now let's say I had another three. Now I should get two.
Okay, that seems to work.
All right, so that one is done and dusted as well.
So next one, check if array contains a value.
So this time we're going to be working with a boolean.
So that is vector it.
Oh no, that's not that. That is let's say contains n vector int array and then in target we're going first we're going to say uh contains is going to be false and then let me show you guys another way of looping. So instead of writing entire blah blah blah uh you can write int number inside of array.
So what this basically means this is another way to loop. We can say for basically we can name this whatever one we can name it X we can name it I we can name it we can name it burger or whatever but let's name it number and then this is going to loop through all of the through the whole array. Again this is the same as a as using a okay so it's not the completed. So it loops to the array. But sometimes you need to use an index and in other cases you can just do this.
So basically I do this when I don't need to use indexes and then I do and you can do this when you don't. Now you have to uh specify the type of the the elements in the array. So this is an element of integer. This is a this is an array of integers. That is why we say integer right here. If we say for example char that's gonna break.
So let's actually uh if r is if if number is equal to target and contains equals true and then we're going to return contains in the end. Now but this is a chart so this is going to throw an error.
So let's say contains n and then r and then whatever. But as we can see as we're going to see we're going to get an error going where is it char number. Okay. So let's say string because chars basically have a asky table representation. We're not going to go into that. If we say string, boom.
Now we get an error. So error conversion from int to nonscalar type string. So this is screaming because what? I can't understand C++. I'm beginner. So okay, bro. Bye-bye. I mean, okay, man. See you. Have a good day, bro.
Okay.
So uh all right so basically this is we say that this is this element is of string type that's why it's cream we need to say that this element is um that this element is the type of the elements in the array. So we're going to say int and this should work now and also we can say we can say auto because for some sometimes you cannot say a data type for example when you are iter when you are using a map when you're using a map data structure to iterate to every pair inside of that map you have to say auto because a pair is not does not have a is not an integer it's not a string it's not I actually could probably Okay. Yeah. Uh yeah, auto basically uh figures out the type of this and then just does this without that. So we should get this as well.
Okay. Now let's get something that is not in the array which is one. We should get zero like that. Okay.
Where are you from? Hello. Hello Shukam.
I am from Eastern Europe.
I am from Eastern Europe. And where are you from? Where are you from? Welcome to the stream, Shupam. I hope you are doing well. Welcome to the stream.
Okay guys, so we did that one.
Okay. Uh, next one. Find the first element greater than x.
Okay. First element. So basically as soon as we find an element greater than x okay let's int first greater let's say vector int of array and we're going to say x first element greater than x is five we get have it.
I'm guessing that there's always going to be a case where there's going to be an element which is greater than x.
So let's say that let's say that our integrator is equal to array of zero.
Right? Now I'm from India. I love India. I love India.
I love India.
Uh okay. So greater is equal to array of zero. Yes.
And then for every Okay, let's do it with indices so it's easier to understand.
Uh size like this.
All right. So, okay, the first greater.
So, if array of I is greater than X, we're going to basically just return return array of I.
Okay.
So we are assuming that okay actually we can return but let's actually break. So what does break do?
Break basically if we say break this means break out of the loop. So if this is true this will break out of the loop at some point and all of the other iterations will not get executed.
Are you in any university or what is your stream? Yes. Uh I am in my final year and I am almost done with university. Yes. How about you? Are you in university or are you working?
Are you in university?
So uh all right. So um for and this.
Okay.
So I have I actually finished university. I actually finished university.
Uh okay. So, and then we're going to actually let's say let's say greater is going to be equal to array of i and then break and then we're going to return greater.
All right.
And this should give. Okay. Actually, I haven't. This is not going to give anything because I haven't just get pass out of university doing Btech. All right. All right. Nice, bro.
Nice. Okay.
Uh Okay. Let's see. Uh what was I doing?
All right. So, see out first greater of r.
Let's say x is three and this should give me eight.
This should give me eight.
Okay, let's say x is x is um no, let's say x is nine. This should give me 10.
Okay. Now I don't know if this function is fully is completely fully proof against every single test case possible but right now it seems to work after DSA what you going to do front end developer or back end I mean I haven't decided yet completely what I'm going to do because I have done some I have done some front end and I have done some I have done mostly front end until now and I don't and I have only a little bit of back end uh and a little bit of full stack so I haven't really decided yet what what about you are you front end are you backend or are you full stack are you front end back end or full stack Okay.
All right.
Okay. So, next one. We did that. Print all elements. Okay. This one.
Okay guys, I think I don't need to explain this one.
Okay.
So we're just going to have an array and we're just going to display the elements of it to the console.
So this is what 5 10 and 15.
Okay. And then we're just going to just going to say void print array.
It's going to be vector int uh array like this. And then for each for each integer in the array, we're going to say we're just going to see out that integer. Let's say even with a new line.
Why not?
So, we're going to print array with R.
I am full stack div and currently working on my SAS. Oh, wow bro. Damn, that's very impressive, man.
Congratulations, bro. That's very impressive.
That's very impressive. What's uh what is your SAS like? What type of product?
What what is your SAS? Like what type of product is it?
What type of what type of product are you making?
Okay. So yeah, print. So we get 5 10 15.
Okay.
Okay. Next one in at even index.
Okay. So basically guys, we already did the is even check. We already solved a problem which uh is get all of the e count all of the even numbers inside of the array. So I think we don't really need to explain how we get an even thing.
Okay. So print. So wait print print even indexes or something and then vector int.
So what do we need to do? So now we are using we need we need to use the index. So we cannot do this. So we're going to have to run a typical for loop like this. And then we're going to if I we can say I in one or we can say for simplicity let's say if I is even we're going to see out R of I like this.
Okay let's get this.
Let's get this.
Get this.
Write this.
And then we're going to say print even indexes of R.
We should get 10 30 0 1 2 3 4 and 50.
10 30 and 50.
Okay.
Is that what we want? Yes. 10, 30, and 50. So, find sum of even elements. So, what does this this combines the We already did how to find the sum and we already did how to find the even L. So, I think this one doesn't need much explaining either.
We are just going to check. We're just going to have a variable total.
And while looping to the array, we are going to check if the current element is even, we're going to add that current element to the array. And if the current element is not even, then we're not going to do anything and just continue with the with the loop.
So let's say even sum of the array we're going to say total is equal to zero going to say for each element if and if it is even no not in array I.
Then we're going to say total plus equals I.
And then we're going to return total.
Okay.
So all right. So what is the this and then see out even sum of r and we should get six. Yes.
Okay. What happened? Even sum of r.
Okay. This seems okay.
Okay. Oh, okay. I didn't do this.
My stopping condition was not there.
Six. Okay. Let's add another even number. Now it should be 14.
All right.
Okay.
So basically I'm making my one-on-one B2C where people come came to book their own appointment with consultant at anywhere in the world. Wow, that sounds pretty cool, bro. Damn, that sounds pretty cool. Awesome, man. That sounds amazing.
Nice. Good job, man. Good job.
Good job.
And how much how much are you planning to charge for for the service? I'm curious to know how much you're planning to charge for the service if if that's okay. If you want to tell me that.
Okay. So, find the largest event number. Okay. So, this is going to be the last one. This is going to be the last one for today.
So, we're going to say int largest even number.
We're going to say vector int r int. Oh, no, we don't need this.
So we're going to say in answer is equal to okay.
Okay, let's say just array of zero and we're going to loop through this largest even number.
largest even number.
Okay, we're going to say we're going to say it's empty right now.
And we're going to say I less than R size I ++ because if we actually what if we do this if we say array of zero this might be so because the condition is going to be it both has to be greater than the last element we picked and it has to be also even.
So let's it can be so only one condition can so maybe if it's so if it's only even or if it's only uh if it's only greater this is not going to happen that's why we get this that's why we do this and if let's say if not answer we're going to say our answer equals R of if not answer and r of i is equal to is even we're going to say answer equals r of i.
else if R of I is even and R of I greater than answer. We're going to say greater than answer. We're going to say answer equals R of I. Then we're going to return answer. Now, this is going to work based on the assumption that there's always going to be a a that there's always going to be a even number in the array. If we get input that is not containing an even number in the array, this is going to break. This is going to break. Okay. So, so let's say largest even number and we should get eight.
Okay, we get some garbage value.
We get some garbage value.
I like what I think not much higher prices. Starting price 30 minute around 500 Indian rupees. What is the employment rate in your country? I mean there are jobs. There are jobs. I'm not complaining.
There are jobs.
Okay guys, I mean, yeah, this one we got kind of stuck on. But guys, this is going to be basically it for today.
Thank you guys so much for joining and yeah, I will see I will see you guys tomorrow. Have a nice day and take care.
Bye bye.
Related Videos
Agentforce NOW AMA: Build with React and Salesforce Multi-Framework
SalesforceDevs
490 views•2026-05-28
How agent o11y differs from traditional o11y — Phil Hetzel, Braintrust
aiDotEngineer
450 views•2026-05-28
Re: 🗣️📍theprophedu📍2026 GST 103 CLASS (E-EXAM REVISION)
theprophedu
636 views•2026-06-04
WEB TECHNOLOGIES UNIT-2 | Degree 4th sem BCOM Computers web technologies unit-2 full explanation💯✅
LearnwithSahera
1K views•2026-05-29
More tests are always better? How to use AI to identify tests that bring little value
Alliance4Qualification
335 views•2026-05-29
Search Algorithms Explained in 60 Seconds! 🤖💨
samarthtuliofficial
218 views•2026-06-01
People of Game of Thrones using JavaScript DOM
AltCampus
296 views•2026-05-30
Instagram accounts got PWNed
EricParker
13K views•2026-06-03











