00:01
Okay, let's write up a quick pseudo code for this algorithm that we want to do the following, which is find the maximum number of an array, find the minimum number, find a difference between the large and the smallest elements, and then count how many elements are bigger than that difference and output that number.
00:20
So let's just call us our algorithm, and we're going to take in our array as inputs.
00:28
So let's go ahead and start writing.
00:30
So the first thing we want to do is find the minimum and the maximum.
00:34
So we're going to do, since you want to do both of those, we should best to do them at the same time since we're going to be looping through the list.
00:42
So that's originally set the max at max int, which is usually infinity, or max should be minimum integer, or minimum number, and min would be the maximum number, so that we usually like infinity or something like that so that we can always have something so that if we don't have a number, then we have the largest minimum or the smallest maximum possible.
01:12
And then so for, let's talk about the element in the array, we're going to loop over the arrays or the array.
01:20
If the elements is less than the max or greater than the maximum, then we want to set this maximum equal to this element, changing the maximum to the new maximum that's been found.
01:33
And in the same case, if it's less than the minimum, it's the minimum equal to the element.
01:40
So now that we have the minimum and the maximum, the difference is just equal to whatever the maximum minus the minimum is, that is the smallest and the largest number...