All language subtitles for 10. A Program to count a total number of “non-unique” values in an array - Solution

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
hu Hungarian Download
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

So before we start coding, we need to understand what are we going to code and what should we do even

in this process?

So the question is how can we find out how many values are not unique in the specific array?

So if we take these five and we found somewhere else on the way, another five, so we can say that

we found out one element, right?

One value literacy.

That is not unique, so five is not unique.

So we proceed on and we do the same process for a three.

Right.

We found the three is not unique because we found another option, another duplication for it.

OK, so we say that three is also non unique value.

And then we move on and we come again to five.

Right.

So do we remember?

That five was already found to be a non unique value.

Probably not, because we do not use here additional space to store additional memory for this array.

OK, we do not create a temporary array for this assistance.

OK.

But what we ask is, OK, so can I find five?

Yeah, there is an additional five.

OK?

So yeah, I should print once again.

Five is none unique value, but that would be wrong because we are interested in just the actual values

themselves that we need to print.

OK, so a lot of mistakes, I assume, happen just on this stage right here.

So you would have been five, three and five three and a total of nine unique values.

But that's not true because values are only two, five and three that are not unique.

So one of the options, of course, once again, I'm saying this is a kind of beginner s material,

so I'm going to show you an option how to do it.

It may be optimized.

I'm leaving it to you, but for now, it's just sufficient for us to make it work and to understand

the basic algorithmic approach.

So what we will do is we will take every time some value.

Let's call it with index AI and we will take every time some value with Index G.

And we will compare I with any of the optional JS, and if we will find a duplication, we'll print

five is none unique and and also edit to some counter of none unique values.

OK, but how do we treat the previous problem that we had?

So for example, we have something like that.

So we have I use five and we start j from here.

So we will ask the following question we will separated into two parts.

We will say if we found.

If we found anything on the left side of the settlement that equals to the actual value itself, then

it means that we took into account these value already by now in the list of the nine unique elements.

Right.

So if we compare five with five, we will be able to say that we already found out that these five,

because we started from left to right, we will be able to say that these five value is already being

taken care of and it has already been taken into account.

And whenever we will reach J equals to II right, we will ask the following question if we did not find

anything so far.

So that means that these values definitely we need not take it into account and we can take a look to

the right and see if it exists again there.

If he does, then we it means that we need to take this into account this value, if not.

So basically, that was kind of unique value.

And that's it.

Okay, so you feel me so far.

Also, we do the same for, for example, three.

OK, so we'll take a look if there was any three on the left that we already took into account.

So that's very important part to split it up to the left part and to the right part.

Of course, you can think of any suggest that additional solutions to solve it, but for now, I think

that would be one of the easiest ones.

OK, so awesome, let's try now to what to do to optimize the solution that was previously discussed

in one of the previous exercises.

So when we took a look at.

At unique values.

So let's call it now, none unique.

Count will create some value input summary OK, no problem.

And now we will start to iterate from equal to zero eyes less than 10 and J equals to zero js less than

10.

But what will we do?

What will we do?

And should we adjust at least a little bit?

These for a loop to support these part.

And the answer is absolutely yes.

Let us see how.

OK.

And if we want to keep on working only with the left side, so there is one thing that we need to ask

ourselves what he is and what is the definition of the left side?

Because on every iteration, for every of the elements that we are going to work with, it is going

to be maybe different rights on the left side.

How can we define it for a specific element at indexing what eats its left side?

So the left side, for any value that is represented by the index i the left side is simply specified

as long as J is less than I.

So the left side is specified by that.

So that's why we will specify here as long as J is less than I will start J from zero, as long as JS

less than I, meaning we did not reach the actual element, but rather one on the left.

Then what we do is we do J Plus Plus and then what we ask, we will ask a very simple question.

We will remove this one.

It's not necessary.

We will ask if values at Index II equals two values that index.

Meaning if there is at least one element on the left side of this element meaning before it, then it

means that we already found a duplicate.

OK, and we found a duplicate will set it up to be one case.

So we know that on the left side, there is already a duplicate, for example, of five, but we also

took it into account.

So that way we will need to ask the following question we will need to ask, let's remove this part,

OK, so it will not bother us.

We will need to ask the following question let's say, OK, so that's the first if and then once we

are done with this for a loop.

So we ask after using these break, we ask the following question if found duplicate equals to one,

if it equals to one, meaning we found a duplicate on the left side of a current element that we are

observing the current element at Index II.

And if that's the case, what we can do is we can also break from the outer loop.

Right, we can break from these outer outer loop because we know that these value, there is no reason

to check it with all the elements on its right because we know that the value itself is already has

been taken care of and where it has been taken care of in the previous part.

And that's we're now.

The else for this section, meaning you found duplicate was not found on the left side.

If it was not found on the left side, then it means that these value can also still be unique or Anani

unique value.

OK, you feel me so far it can be unique or not unique, so we will need to check this value with any

of the other values on the right side.

And if we will find that these value at index site will be equal to any of the values in the right side,

starting from these jobs until the size of the array of minus one size minus one.

Basically, if we will find a duplicate there, then we will need to take into account these value.

So how can we do it?

So these L.S. will run the following part of the code we will say J equals two.

What from what index do we start their eight part?

We started from I +1 right because the right part of these value add indexes starts from J equals two

i +1.

And as long as it's less than the size or in this case, it's just 10, OK, you can define it whatever

you want, J + +.

So that will refer to working with the right side.

OK, so previously it was the left side.

Now it's the right side, and we will ask inside of these for a loop, a simple question what is it?

Come here, come here.

Come here.

We will ask inside of these for a loop.

A simple question.

We will ask if values at index say even equals to value set index j, then in this case, what you should

do.

You should print some message.

OK, so like something like non unique value.

Is percentage, I don't know, expression here specified the actual value that you want to print.

Is it clear also let's take non-Sunni count plus plus and there is no need to continue, so we will

simply break from this for a loop as well.

Okay.

So if we found out that it was equal, otherwise found duplicate will still remain zero.

Well, basically, yeah, I think we can also add here found duplicate equal to zero or start with every

iteration nullified.

And yeah, that's it.

That's the part of working with the right side.

So we start with the index one to the right of the index that we are working with.

And we ask if values in IXI equals value it SJ found a duplicate, then we can say that this value is

none unique value printed.

It added it to the account.

And that's it.

So the main difference is that we've made is simply by distinguishing between the left part so far and

the right part.

So before celebrating, OK, let's make sure that everything here works exactly as we expected.

Yeah, OK, so let's build and run it.

Yeah, I see that we had got some errors.

Let's try to figure out what are the problems.

So unique count with his unique count on.

OK, of course, we modified the the name of this variable, so now it's my unique count.

Let's build it.

Come on.

Work.

OK, so what are the values?

Let's get it like this will be nice to see.

So values are five seven.

Three, four, five six eight, eight five, OK.

Never mind.

Nine, 10 and three, OK.

And we really hope these will work.

If not, we will make corrections.

OK, because that's the part of developing.

Don't worry if we will get problems.

But in this case, it seems that we've made everything correctly.

We get nine unique value equals to five and nine.

Unique value equals to three total unique numbers equals to two total none.

Uniqueness.

It should be none.

None unique.

Nine unique names.

OK.

So total non unique values, but that's just the message.

So I hope that's clear to you guys.

Very important, very interesting video, very interesting exercise of how we can split it into two

parts of things that we have processed so far and things that we have not processed so far.

Because you see this knowledge and this understanding, I think it's kind of moving further in understanding

the material.

So thank you guys for watching.

Keep on practicing.

If you have any questions, always feel free to ask if you think there are a couple of improvements

that can be made to solve it more efficiently.

Maybe there is that saying there are not, so feel free to share it.

OK, and maybe in the further questions and further sections, maybe we will also talk about how we

can improve the performance of some of the solutions that we've made so far in this course.

So once again, thank you, guys.

My name is Vlad Alfa Tech.

I'll see you next time.

Bye.

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