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
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:01,080 --> 00:00:07,560 So before we start coding, we need to understand what are we going to code and what should we do even 2 00:00:07,560 --> 00:00:08,580 in this process? 3 00:00:09,450 --> 00:00:16,860 So the question is how can we find out how many values are not unique in the specific array? 4 00:00:17,670 --> 00:00:25,380 So if we take these five and we found somewhere else on the way, another five, so we can say that 5 00:00:25,380 --> 00:00:28,560 we found out one element, right? 6 00:00:28,560 --> 00:00:30,360 One value literacy. 7 00:00:31,550 --> 00:00:34,760 That is not unique, so five is not unique. 8 00:00:38,210 --> 00:00:41,210 So we proceed on and we do the same process for a three. 9 00:00:41,270 --> 00:00:41,720 Right. 10 00:00:42,170 --> 00:00:48,410 We found the three is not unique because we found another option, another duplication for it. 11 00:00:48,710 --> 00:00:51,740 OK, so we say that three is also non unique value. 12 00:00:54,520 --> 00:00:57,010 And then we move on and we come again to five. 13 00:00:58,030 --> 00:00:58,420 Right. 14 00:00:59,390 --> 00:01:01,430 So do we remember? 15 00:01:02,400 --> 00:01:07,020 That five was already found to be a non unique value. 16 00:01:08,020 --> 00:01:14,530 Probably not, because we do not use here additional space to store additional memory for this array. 17 00:01:14,650 --> 00:01:18,700 OK, we do not create a temporary array for this assistance. 18 00:01:18,790 --> 00:01:19,240 OK. 19 00:01:19,810 --> 00:01:23,420 But what we ask is, OK, so can I find five? 20 00:01:23,440 --> 00:01:24,900 Yeah, there is an additional five. 21 00:01:24,910 --> 00:01:25,270 OK? 22 00:01:25,300 --> 00:01:27,220 So yeah, I should print once again. 23 00:01:27,220 --> 00:01:33,340 Five is none unique value, but that would be wrong because we are interested in just the actual values 24 00:01:33,340 --> 00:01:35,710 themselves that we need to print. 25 00:01:36,520 --> 00:01:41,740 OK, so a lot of mistakes, I assume, happen just on this stage right here. 26 00:01:42,100 --> 00:01:47,110 So you would have been five, three and five three and a total of nine unique values. 27 00:01:47,110 --> 00:01:52,000 But that's not true because values are only two, five and three that are not unique. 28 00:01:52,750 --> 00:01:59,050 So one of the options, of course, once again, I'm saying this is a kind of beginner s material, 29 00:01:59,290 --> 00:02:02,710 so I'm going to show you an option how to do it. 30 00:02:03,250 --> 00:02:05,650 It may be optimized. 31 00:02:05,800 --> 00:02:11,620 I'm leaving it to you, but for now, it's just sufficient for us to make it work and to understand 32 00:02:11,620 --> 00:02:13,690 the basic algorithmic approach. 33 00:02:14,920 --> 00:02:18,510 So what we will do is we will take every time some value. 34 00:02:18,520 --> 00:02:24,930 Let's call it with index AI and we will take every time some value with Index G. 35 00:02:26,980 --> 00:02:33,100 And we will compare I with any of the optional JS, and if we will find a duplication, we'll print 36 00:02:33,100 --> 00:02:39,220 five is none unique and and also edit to some counter of none unique values. 37 00:02:40,570 --> 00:02:43,540 OK, but how do we treat the previous problem that we had? 38 00:02:43,540 --> 00:02:46,170 So for example, we have something like that. 39 00:02:46,180 --> 00:02:51,190 So we have I use five and we start j from here. 40 00:02:52,090 --> 00:02:56,860 So we will ask the following question we will separated into two parts. 41 00:02:57,370 --> 00:02:59,560 We will say if we found. 42 00:03:00,920 --> 00:03:10,250 If we found anything on the left side of the settlement that equals to the actual value itself, then 43 00:03:10,250 --> 00:03:18,740 it means that we took into account these value already by now in the list of the nine unique elements. 44 00:03:19,190 --> 00:03:19,490 Right. 45 00:03:19,490 --> 00:03:25,610 So if we compare five with five, we will be able to say that we already found out that these five, 46 00:03:25,700 --> 00:03:32,480 because we started from left to right, we will be able to say that these five value is already being 47 00:03:32,480 --> 00:03:36,470 taken care of and it has already been taken into account. 48 00:03:37,490 --> 00:03:44,600 And whenever we will reach J equals to II right, we will ask the following question if we did not find 49 00:03:44,840 --> 00:03:46,010 anything so far. 50 00:03:46,460 --> 00:03:53,510 So that means that these values definitely we need not take it into account and we can take a look to 51 00:03:53,510 --> 00:03:57,290 the right and see if it exists again there. 52 00:03:57,800 --> 00:04:03,860 If he does, then we it means that we need to take this into account this value, if not. 53 00:04:03,860 --> 00:04:06,520 So basically, that was kind of unique value. 54 00:04:06,530 --> 00:04:07,340 And that's it. 55 00:04:08,450 --> 00:04:09,980 Okay, so you feel me so far. 56 00:04:10,760 --> 00:04:13,000 Also, we do the same for, for example, three. 57 00:04:13,010 --> 00:04:20,390 OK, so we'll take a look if there was any three on the left that we already took into account. 58 00:04:21,170 --> 00:04:27,410 So that's very important part to split it up to the left part and to the right part. 59 00:04:27,860 --> 00:04:33,440 Of course, you can think of any suggest that additional solutions to solve it, but for now, I think 60 00:04:33,440 --> 00:04:35,810 that would be one of the easiest ones. 61 00:04:36,940 --> 00:04:44,560 OK, so awesome, let's try now to what to do to optimize the solution that was previously discussed 62 00:04:44,560 --> 00:04:46,240 in one of the previous exercises. 63 00:04:46,780 --> 00:04:49,540 So when we took a look at. 64 00:04:51,400 --> 00:04:52,600 At unique values. 65 00:04:52,930 --> 00:04:56,420 So let's call it now, none unique. 66 00:04:56,950 --> 00:05:01,690 Count will create some value input summary OK, no problem. 67 00:05:02,080 --> 00:05:09,280 And now we will start to iterate from equal to zero eyes less than 10 and J equals to zero js less than 68 00:05:09,280 --> 00:05:09,580 10. 69 00:05:10,450 --> 00:05:11,500 But what will we do? 70 00:05:12,040 --> 00:05:13,060 What will we do? 71 00:05:13,060 --> 00:05:16,450 And should we adjust at least a little bit? 72 00:05:16,540 --> 00:05:19,330 These for a loop to support these part. 73 00:05:19,690 --> 00:05:22,030 And the answer is absolutely yes. 74 00:05:22,540 --> 00:05:23,350 Let us see how. 75 00:05:24,890 --> 00:05:25,400 OK. 76 00:05:25,460 --> 00:05:32,060 And if we want to keep on working only with the left side, so there is one thing that we need to ask 77 00:05:32,060 --> 00:05:36,230 ourselves what he is and what is the definition of the left side? 78 00:05:36,350 --> 00:05:41,390 Because on every iteration, for every of the elements that we are going to work with, it is going 79 00:05:41,780 --> 00:05:44,630 to be maybe different rights on the left side. 80 00:05:45,470 --> 00:05:50,900 How can we define it for a specific element at indexing what eats its left side? 81 00:05:51,710 --> 00:06:01,820 So the left side, for any value that is represented by the index i the left side is simply specified 82 00:06:01,820 --> 00:06:04,550 as long as J is less than I. 83 00:06:04,970 --> 00:06:08,240 So the left side is specified by that. 84 00:06:08,870 --> 00:06:16,130 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 85 00:06:16,130 --> 00:06:22,040 less than I, meaning we did not reach the actual element, but rather one on the left. 86 00:06:23,110 --> 00:06:31,420 Then what we do is we do J Plus Plus and then what we ask, we will ask a very simple question. 87 00:06:31,930 --> 00:06:33,500 We will remove this one. 88 00:06:33,520 --> 00:06:34,500 It's not necessary. 89 00:06:34,510 --> 00:06:39,310 We will ask if values at Index II equals two values that index. 90 00:06:39,730 --> 00:06:48,700 Meaning if there is at least one element on the left side of this element meaning before it, then it 91 00:06:48,700 --> 00:06:51,280 means that we already found a duplicate. 92 00:06:52,000 --> 00:06:56,350 OK, and we found a duplicate will set it up to be one case. 93 00:06:56,350 --> 00:07:02,020 So we know that on the left side, there is already a duplicate, for example, of five, but we also 94 00:07:02,020 --> 00:07:03,370 took it into account. 95 00:07:03,910 --> 00:07:10,140 So that way we will need to ask the following question we will need to ask, let's remove this part, 96 00:07:10,150 --> 00:07:11,800 OK, so it will not bother us. 97 00:07:12,340 --> 00:07:18,670 We will need to ask the following question let's say, OK, so that's the first if and then once we 98 00:07:18,670 --> 00:07:21,190 are done with this for a loop. 99 00:07:21,190 --> 00:07:29,170 So we ask after using these break, we ask the following question if found duplicate equals to one, 100 00:07:29,620 --> 00:07:36,250 if it equals to one, meaning we found a duplicate on the left side of a current element that we are 101 00:07:36,790 --> 00:07:39,280 observing the current element at Index II. 102 00:07:39,550 --> 00:07:46,270 And if that's the case, what we can do is we can also break from the outer loop. 103 00:07:47,570 --> 00:07:53,660 Right, we can break from these outer outer loop because we know that these value, there is no reason 104 00:07:53,660 --> 00:08:00,290 to check it with all the elements on its right because we know that the value itself is already has 105 00:08:00,290 --> 00:08:05,750 been taken care of and where it has been taken care of in the previous part. 106 00:08:06,200 --> 00:08:08,210 And that's we're now. 107 00:08:09,510 --> 00:08:15,390 The else for this section, meaning you found duplicate was not found on the left side. 108 00:08:16,080 --> 00:08:24,540 If it was not found on the left side, then it means that these value can also still be unique or Anani 109 00:08:24,540 --> 00:08:25,380 unique value. 110 00:08:25,810 --> 00:08:32,220 OK, you feel me so far it can be unique or not unique, so we will need to check this value with any 111 00:08:32,220 --> 00:08:34,230 of the other values on the right side. 112 00:08:34,920 --> 00:08:41,010 And if we will find that these value at index site will be equal to any of the values in the right side, 113 00:08:41,310 --> 00:08:46,620 starting from these jobs until the size of the array of minus one size minus one. 114 00:08:46,620 --> 00:08:53,100 Basically, if we will find a duplicate there, then we will need to take into account these value. 115 00:08:53,700 --> 00:08:54,790 So how can we do it? 116 00:08:54,810 --> 00:09:01,260 So these L.S. will run the following part of the code we will say J equals two. 117 00:09:01,260 --> 00:09:04,530 What from what index do we start their eight part? 118 00:09:04,830 --> 00:09:12,890 We started from I +1 right because the right part of these value add indexes starts from J equals two 119 00:09:12,900 --> 00:09:13,860 i +1. 120 00:09:14,580 --> 00:09:21,420 And as long as it's less than the size or in this case, it's just 10, OK, you can define it whatever 121 00:09:21,420 --> 00:09:23,340 you want, J + +. 122 00:09:24,180 --> 00:09:29,580 So that will refer to working with the right side. 123 00:09:30,700 --> 00:09:33,290 OK, so previously it was the left side. 124 00:09:33,310 --> 00:09:39,730 Now it's the right side, and we will ask inside of these for a loop, a simple question what is it? 125 00:09:39,760 --> 00:09:41,620 Come here, come here. 126 00:09:41,620 --> 00:09:42,190 Come here. 127 00:09:42,850 --> 00:09:44,560 We will ask inside of these for a loop. 128 00:09:44,560 --> 00:09:45,460 A simple question. 129 00:09:45,460 --> 00:09:53,050 We will ask if values at index say even equals to value set index j, then in this case, what you should 130 00:09:53,050 --> 00:09:53,320 do. 131 00:09:54,070 --> 00:09:55,780 You should print some message. 132 00:09:55,780 --> 00:09:58,810 OK, so like something like non unique value. 133 00:10:00,630 --> 00:10:06,600 Is percentage, I don't know, expression here specified the actual value that you want to print. 134 00:10:07,780 --> 00:10:15,940 Is it clear also let's take non-Sunni count plus plus and there is no need to continue, so we will 135 00:10:15,940 --> 00:10:20,440 simply break from this for a loop as well. 136 00:10:21,310 --> 00:10:21,490 Okay. 137 00:10:21,490 --> 00:10:28,690 So if we found out that it was equal, otherwise found duplicate will still remain zero. 138 00:10:29,080 --> 00:10:36,010 Well, basically, yeah, I think we can also add here found duplicate equal to zero or start with every 139 00:10:36,010 --> 00:10:38,500 iteration nullified. 140 00:10:38,980 --> 00:10:40,140 And yeah, that's it. 141 00:10:40,150 --> 00:10:42,640 That's the part of working with the right side. 142 00:10:43,630 --> 00:10:49,690 So we start with the index one to the right of the index that we are working with. 143 00:10:49,690 --> 00:10:56,650 And we ask if values in IXI equals value it SJ found a duplicate, then we can say that this value is 144 00:10:56,650 --> 00:10:58,850 none unique value printed. 145 00:10:58,850 --> 00:11:00,490 It added it to the account. 146 00:11:00,490 --> 00:11:01,300 And that's it. 147 00:11:01,840 --> 00:11:08,140 So the main difference is that we've made is simply by distinguishing between the left part so far and 148 00:11:08,140 --> 00:11:08,980 the right part. 149 00:11:09,940 --> 00:11:15,610 So before celebrating, OK, let's make sure that everything here works exactly as we expected. 150 00:11:16,150 --> 00:11:17,950 Yeah, OK, so let's build and run it. 151 00:11:18,730 --> 00:11:21,060 Yeah, I see that we had got some errors. 152 00:11:21,070 --> 00:11:23,740 Let's try to figure out what are the problems. 153 00:11:25,490 --> 00:11:27,810 So unique count with his unique count on. 154 00:11:27,920 --> 00:11:33,980 OK, of course, we modified the the name of this variable, so now it's my unique count. 155 00:11:35,160 --> 00:11:35,940 Let's build it. 156 00:11:36,180 --> 00:11:36,630 Come on. 157 00:11:36,930 --> 00:11:37,380 Work. 158 00:11:39,520 --> 00:11:41,410 OK, so what are the values? 159 00:11:41,470 --> 00:11:43,630 Let's get it like this will be nice to see. 160 00:11:44,050 --> 00:11:47,290 So values are five seven. 161 00:11:48,350 --> 00:11:52,220 Three, four, five six eight, eight five, OK. 162 00:11:52,320 --> 00:11:53,450 Never mind. 163 00:11:54,380 --> 00:11:56,930 Nine, 10 and three, OK. 164 00:11:56,930 --> 00:11:58,640 And we really hope these will work. 165 00:11:58,910 --> 00:12:00,620 If not, we will make corrections. 166 00:12:00,650 --> 00:12:03,480 OK, because that's the part of developing. 167 00:12:03,530 --> 00:12:05,570 Don't worry if we will get problems. 168 00:12:06,050 --> 00:12:09,110 But in this case, it seems that we've made everything correctly. 169 00:12:09,110 --> 00:12:11,720 We get nine unique value equals to five and nine. 170 00:12:11,720 --> 00:12:17,090 Unique value equals to three total unique numbers equals to two total none. 171 00:12:17,090 --> 00:12:17,680 Uniqueness. 172 00:12:18,110 --> 00:12:19,520 It should be none. 173 00:12:20,240 --> 00:12:21,220 None unique. 174 00:12:22,360 --> 00:12:23,470 Nine unique names. 175 00:12:25,260 --> 00:12:25,630 OK. 176 00:12:25,680 --> 00:12:29,520 So total non unique values, but that's just the message. 177 00:12:30,030 --> 00:12:31,520 So I hope that's clear to you guys. 178 00:12:31,530 --> 00:12:36,660 Very important, very interesting video, very interesting exercise of how we can split it into two 179 00:12:36,660 --> 00:12:42,120 parts of things that we have processed so far and things that we have not processed so far. 180 00:12:42,450 --> 00:12:50,400 Because you see this knowledge and this understanding, I think it's kind of moving further in understanding 181 00:12:50,400 --> 00:12:51,180 the material. 182 00:12:51,990 --> 00:12:53,400 So thank you guys for watching. 183 00:12:53,430 --> 00:12:54,570 Keep on practicing. 184 00:12:54,570 --> 00:12:59,970 If you have any questions, always feel free to ask if you think there are a couple of improvements 185 00:12:59,970 --> 00:13:03,120 that can be made to solve it more efficiently. 186 00:13:03,600 --> 00:13:07,800 Maybe there is that saying there are not, so feel free to share it. 187 00:13:07,890 --> 00:13:15,540 OK, and maybe in the further questions and further sections, maybe we will also talk about how we 188 00:13:15,540 --> 00:13:21,420 can improve the performance of some of the solutions that we've made so far in this course. 189 00:13:22,270 --> 00:13:24,120 So once again, thank you, guys. 190 00:13:24,150 --> 00:13:25,720 My name is Vlad Alfa Tech. 191 00:13:25,740 --> 00:13:26,860 I'll see you next time. 192 00:13:26,940 --> 00:13:27,390 Bye. 17917

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