All language subtitles for 16. Continue (Upgrade2) Rotate RIGHT a given array by N positions - Solution

af Afrikaans
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bn Bengali
bs Bosnian
bg Bulgarian
ca Catalan
ceb Cebuano
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
tl Filipino
fi Finnish
fr French
fy Frisian
gl Galician
ka Georgian
de German
el Greek
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian Download
is Icelandic
ig Igbo
id Indonesian
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
km Khmer
ko Korean
ku Kurdish (Kurmanji)
ky Kyrgyz
lo Lao
la Latin
lv Latvian
lt Lithuanian
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mn Mongolian
my Myanmar (Burmese)
ne Nepali
no Norwegian
ps Pashto
fa Persian
pl Polish
pt Portuguese
pa Punjabi
ro Romanian
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
st Sesotho
sn Shona
sd Sindhi
si Sinhala
sk Slovak
sl Slovenian
so Somali
es Spanish
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
te Telugu
th Thai
tr Turkish
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
or Odia (Oriya)
rw Kinyarwanda
tk Turkmen
tt Tatar
ug Uyghur
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:00,630 --> 00:00:04,920 OK, so let's take a look at what should be done in the solution. 2 00:00:05,940 --> 00:00:13,170 Basically, once we implement just the part of rotating by one to the right, then I think it shouldn't 3 00:00:13,170 --> 00:00:22,380 be much of a problem to make the rotations right by end positions, which should be pretty much the 4 00:00:22,380 --> 00:00:22,770 same. 5 00:00:22,770 --> 00:00:25,830 So we will leave the outer loop as is. 6 00:00:26,250 --> 00:00:28,590 We will use temp equal to want. 7 00:00:28,800 --> 00:00:29,600 What do we know? 8 00:00:29,610 --> 00:00:31,230 What do we want to take into account? 9 00:00:31,680 --> 00:00:39,030 So first of all, let's start and understand basically the main steps for implementing rotate by one. 10 00:00:39,930 --> 00:00:43,950 So we want all of them to move by one element to the right. 11 00:00:44,250 --> 00:00:44,730 OK. 12 00:00:44,760 --> 00:00:47,130 That's what we want to do using some for a loop. 13 00:00:47,550 --> 00:00:48,510 Probably, right? 14 00:00:50,110 --> 00:00:55,660 But we don't need and we don't want these value the right most value to be. 15 00:00:57,260 --> 00:01:05,630 To be basically deleted with the value of seven when we rotate to the right because we did not use it 16 00:01:05,630 --> 00:01:06,680 right here yet. 17 00:01:07,850 --> 00:01:10,820 So what we will create, we will create a temp variable. 18 00:01:11,210 --> 00:01:15,950 And now these temp variable will be for inserting these for a loop. 19 00:01:16,280 --> 00:01:27,140 We will put it a value of three or basically the final element in the value series or values a at index 20 00:01:27,140 --> 00:01:28,640 size minus one. 21 00:01:30,580 --> 00:01:37,360 OK, that's what we'll go to temp and then we will use a for a loop, for a loop that should start from 22 00:01:37,360 --> 00:01:43,960 where if we will start the for a loop from equal to one, as long as is less than size and do something 23 00:01:43,960 --> 00:01:51,400 very similar, then it may be kind of a problem because if we put five here, then on the next iteration 24 00:01:51,730 --> 00:01:52,930 we lost the four. 25 00:01:54,100 --> 00:02:01,930 So we should start maybe from another way, another option because we do not want to lose track of any 26 00:02:01,930 --> 00:02:02,560 value. 27 00:02:03,190 --> 00:02:08,200 We may start with the value of size minus one, right? 28 00:02:08,320 --> 00:02:16,290 Start from this value right here and we will do that as long as I is greater than zero or one will see 29 00:02:16,300 --> 00:02:16,990 right away. 30 00:02:18,100 --> 00:02:24,520 And basically, we will say that every time that, first of all, we will put here the value of the 31 00:02:24,520 --> 00:02:25,630 element on its left. 32 00:02:26,820 --> 00:02:33,240 So we will place here at 7:00, then we will move to this one, we will place here for the valley on 33 00:02:33,240 --> 00:02:33,720 its left. 34 00:02:34,080 --> 00:02:37,110 We will place here five when equal to one. 35 00:02:37,650 --> 00:02:42,570 And when I pull to zero, we will not do anything, so we'll basically stop. 36 00:02:43,530 --> 00:02:49,290 So as long as I is greater than zero, then we are going to do this operation. 37 00:02:50,500 --> 00:02:56,800 And finally, after words, we will put the value in sitemap to the left most element. 38 00:02:57,920 --> 00:02:59,810 And we will get here at 3:00. 39 00:03:00,920 --> 00:03:08,090 So is there anything clear if you have any questions, feel free to ask them in the U.S. and we will 40 00:03:08,090 --> 00:03:09,410 gladly answer them. 41 00:03:10,160 --> 00:03:14,360 So let's try to figure out now what we should change and what we should modify. 42 00:03:14,780 --> 00:03:21,020 So this part of the explanation is one of the most important parts that you need to be familiar with 43 00:03:21,020 --> 00:03:25,490 in order to basically to know how to approach this exercise. 44 00:03:26,570 --> 00:03:29,840 So what we will do is we will say temp will be equal. 45 00:03:29,930 --> 00:03:30,320 OK? 46 00:03:30,560 --> 00:03:35,240 This part refers to rotating by one to the right. 47 00:03:36,240 --> 00:03:44,070 OK, given away so it will be equal to value, zero are at index size minus one the right most element. 48 00:03:44,790 --> 00:03:50,640 And then we will start from i.e. equal to what equal to size minus one. 49 00:03:51,300 --> 00:03:54,180 That's the index of the right most element. 50 00:03:54,510 --> 00:04:03,380 As long as I is greater than what then zero, but not included I minus minus. 51 00:04:03,660 --> 00:04:04,020 OK. 52 00:04:04,060 --> 00:04:05,340 That's what we are going to do. 53 00:04:06,640 --> 00:04:16,120 And on every iteration, what we want to do is to take the value of the previous, the value on of the 54 00:04:16,120 --> 00:04:20,770 element on the left and to put it inside here. 55 00:04:21,400 --> 00:04:24,520 Okay, so what what did we have previously? 56 00:04:25,330 --> 00:04:26,530 Let me get it back. 57 00:04:27,010 --> 00:04:28,510 What did we have previously? 58 00:04:28,510 --> 00:04:31,280 We had like five four, seven three. 59 00:04:31,300 --> 00:04:33,070 So we want seven here. 60 00:04:33,790 --> 00:04:37,840 So what we will do is, come on, what happened? 61 00:04:38,820 --> 00:04:39,090 Yeah. 62 00:04:39,220 --> 00:04:48,210 Okay, so we will see the value in this specific index right now should be equal to the value on what? 63 00:04:48,780 --> 00:04:49,560 On my left. 64 00:04:51,240 --> 00:04:51,680 OK. 65 00:04:52,650 --> 00:05:00,780 And that kind of ensures also I'm minus one, you know, that the the largest index is equal to one. 66 00:05:01,020 --> 00:05:02,850 So you will not basically. 67 00:05:04,070 --> 00:05:05,510 Go out of bounds. 68 00:05:06,710 --> 00:05:10,970 So once you are done with it, all you will have is this array. 69 00:05:12,310 --> 00:05:13,420 Like that? 70 00:05:13,870 --> 00:05:15,100 OK, so you will have 71 00:05:17,620 --> 00:05:18,370 five. 72 00:05:20,070 --> 00:05:21,720 Four seven. 73 00:05:22,290 --> 00:05:30,570 And also here will be five in the final step, which is this one will be used for what the reporting 74 00:05:30,570 --> 00:05:32,970 values the error at index zero. 75 00:05:33,960 --> 00:05:34,290 OK. 76 00:05:34,320 --> 00:05:36,630 With the value inside of variable temp. 77 00:05:37,320 --> 00:05:40,710 So the final result should be like this. 78 00:05:41,490 --> 00:05:43,560 Three five four seven. 79 00:05:44,370 --> 00:05:47,400 That's the rotation by one to their right. 80 00:05:48,060 --> 00:05:49,320 That's all that happened. 81 00:05:50,070 --> 00:05:54,480 And now once once we close it using this outer loop. 82 00:05:55,940 --> 00:06:02,870 We do this operation over and over how many times and times that's what we do. 83 00:06:04,160 --> 00:06:06,710 Is it clear that's it? 84 00:06:07,010 --> 00:06:09,560 Thank you for watching and enjoy. 7416

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