All language subtitles for 10. Good Multiplication Neighbors

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranรฎ)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu

Original subtitles

All right, what is going on, ladies and gentlemen, and in this video, we are going to solve some

interesting exercise regarding our work with neighbors.

So we have to do now is just the basic exercise, using a raise and using some conditions.

And what we are required to do is to write a program that creates an array of integers.

So that would be our first step.

And the program should check and print of the array has at least one element with good neighbors.

And of course, the definition for good neighbors can be like really different.

Right, because there may be good neighbors that I don't know does not do not make noise after, I don't

know, 10:00 p.m. and there may be like other neighbors that are simply kind people and they say good

morning and good night.

And also there may be other neighbors as well.

And basically in this exercise, what we have to do is simply to define what is a good neighbor and

basically a good neighbor.

And an array with a good neighbor sees an array that has at least one element with good neighbors has

a value that equals to the multiplication of both of its neighbors on their right and on the left.

And I think the best idea, the best option to explain it is simply to watch these exercise, watch

these two examples.

So we said that an array with good neighbors is considered to be an array that has at least one element.

That is the multiplication they think its value equals to the multiplication on the of the element on

their left and of the element on the right.

So in this case, we know that we ask the question, does three equals to one multiplied by two?

And if that's the case, then this array can be considered is array that has good neighbors.

But in this case, that's not the answer to this, not the question yet, because three does not equal

to one multiplied by two.

So then we go to the next element and we ask two, does it equal two equals two three multiplied by

six?

No, of course the answer is no.

Then we move on to the next element and we ask, does six equals two the multiplication between two

and three?

Yes, that's the case.

Six equals to two multiplied by three.

Then in this case, we can say absolutely that this array has good neighbors, OK, because it has at

least one element that its value equals to the multiplication between the element on its left and the

element on its right.

And if we will take a look at the second example, we will see that there is no element that satisfies

this condition, that the multiplication of the right and left elements gives basically the value of

the given element.

OK, awesome.

So that's basically are the instructions for this exercise and now what we have to do is simply to start

implementing it.

So let us start and the first thing that we have to do is just use the following call.

It's create.

And I know my array of size.

I don't know.

Let's make it five and let's of course, we can use some functions to read the input from the user.

But yeah, also we can do that.

So in my array of size five.

Yeah.

So let's go like this.

So pretty def basically also I for I equals to zero.

I have less than five Ibos plus course.

The value and the size of the array could have been defined using the defined structure here or something

like that to define size font size five.

But yeah let's, let's also use the size here.

No problem with that.

It's simply the same as we've written five.

Right.

Awesome.

So now let's read the information from the users or print out enter value percentage be OK and then

the user is going to enter.

His value is going to be like what value to be plus one enter value one, value two and so on.

And now you can have percentage the installed inside.

Inside where my error are it index what index site excite.

So make sure you don't really mess up at this step ok.

When you read the information from the user and store it inside the arrays elements.

OK, that's also very important.

Awesome.

So this step is over and now we have to basically once we've read the information and we've constructed

the array from the user, what do we have to do is simply to implement these logic of the good neighbors

and how should we do that?

How should we do it?

So we said that we have this array and we are interested in finding the.

And what are we interested in finding the neighbors, the multiplication of the neighbors.

And one of the things here is basically to understand that for every element that we are going to check,

it's very important to make sure that we are we do we check both of its elements, let's say at index.

I end at the index in minus one and at index I plus one.

OK, so an element on the left and the element on the right.

But the main question comes here basically what should be the boundaries?

Because this element, as well as this element, they are basically on the corners of this array and

they don't have either the left or neighbor or the right neighbor.

So in this case, we know that they are out of limits as well, because we simply if we would have checked

the multiplication between are neighbors and we would have tried to access this place, he does not

belong to the array and also maybe does not also belong to the program.

And then you will simply get some access violation.

And that's not something that we want to do because that also doesn't make any sense.

All right.

Now, let us try to run the loop, so for and with watching this, should we start, I suggest to start

with index one.

And why is that?

Because the index one is the second element in our programming language.

And we said that the leftmost element, the first element is not something that we want to start with.

OK, so I equals to one as long as I is less than size.

OK, I plus plus.

So my question is, do you think that this condition of as long as I is less than size is OK because

I mean these three are these loop will be executed as long as I is less than five.

Meaning for I equals two for this loop should also be executed and it should check the element on the

left as well as the element on the right.

So if you would have taken a look at this one.

OK, so this value is at index four because index zero, index one, index two, index three and index

for them.

These value alignment would we said that we do not want to check it out.

So that's why we will say as long as I is less than size minus one, not taking into account the last

element in this array.

All right.

So now let us ask a simple question.

You know, this question goes like this.

If if my error, OK, at Index I equals to my error it index I plus or minus one, the index on the

left, the value on the left multiplied by my Iran it index plus one, the value on the right.

Then if that's the case then what we should do is simply to print that this array that this array has

good neighbors, basically something like that, something like this message.

So let's do it like this are this array has good neighbors.

Neighbours.

Yeah, this array has good neighbours.

And one question that I'm going to ask you here is, what do you think should happen now?

Should basically we leave it as is or maybe you have an idea of something that we can add to make this

problem even better?

OK, but so far, if you have any questions, feel free to stop the video and ask them, OK, I'll do

my best to answer any of your questions.

Maybe if you know and if you see students that are struggling OK and they have questions that for some

reason are on answer, feel free to answer them.

That's also part of the learning process to help one another.

And that's how you are getting better and better in programming while also answering other people questions

and discussions.

OK, so if we will live in this way, OK, and we will have at least more than just one element, then

these are message.

If we will have more than just one element with that satisfies the condition of having good neighbors,

then this message will be printed, I don't know, five, 10, 15 times.

Right, maybe.

And that's not something that we want.

Also, what we don't want is to spend any resources once we found out that this condition happens to

be true.

OK, so, I mean, if this condition happens to be true, then there is no reason to pretend to continue

executing this loop because otherwise how if this condition is not true, how will be will we be even

able to print this array does not have good neighbors.

OK, so that's another message that we have to take care of.

So one of the things that may be used here is simply to use a flag.

OK, I don't know, something like that and has good neighbors.

And this flag will be one assuming that they are good neighbors.

OK, or let's assume that or has good neighbors.

Now, we will assume that before these, Iraq does not have good neighbors.

OK, so assumption assumption Ray does not have does not have good neighbors.

Doesn't really matter.

We can solve it with two ways, but let's think with this one.

OK, so if that's the case, ok, then we can say that has good neighbors will be equal to one.

OK, this flag will specify basically that we found out at least one element that satisfies the condition

of having good neighbors.

And in this case, what we will use is just setting of this flag.

That array has good neighbors, OK, has good neighbors.

Awesome.

And also what I suggest is to add these brake line.

OK, so there are so that if we have, like, I don't know, large arrays and so on, that these operations

will not go any further because we found out that this array has good neighbors.

Awesome.

And outside of these for a loop, we can ask a simple question if his neighbors equals to zero, right.

If he has good neighbors, flag equals to zero.

Letting these guys bring F print f what should we print?

This array does not have any good neighbors, any good, good neighbors.

Awesome.

So maybe you guys are maybe maybe maybe.

I'm just saying maybe there are a couple of options to solve this exercise.

OK, that's one of them.

OK, that's one of them.

Oh.

Another option may also be like to move this message out of here also too.

I'm just going to show you now a couple of options that I can think of.

Probably.

Yeah.

That basically will look like this.

Or else if he has good neighbors equals to one, then in this case print this message.

OK, so that's the other way around.

Third way can be like this to you.

Leave it as it was previously.

Let's think about it.

I don't know, maybe something like that.

Where is it.

What happened.

Oh sorry.

We were like here, right.

Yeah.

So another option is simply to use it like this.

So remove this if condition, leave these print as a default, OK, is a default in here instead of

the brake, which is the return zero because we know that also the main also function.

And if these returns zero will be executed, then the program should stop right from here, right after

this line.

OK, and these lines will only be executed only if this array does not have any good neighbors.

Of course, there are also like base cases that can be taken care of you.

The array has one element and so on and so forth.

But I'm not jumping into it because I don't think it's it's mandatory at this point.

So, yeah.

Guys, thank you so much for watching.

Keep on practicing.

Let me know what you think of.

This video, and of course, so far, your review and your participation is really of great importance

for me, it helps me a lot and it helps other students as well.

So thank you so much.

And until next time.

My name is Vlad.

This is Alphatech Academy.

And I'll see you then.

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.