Arrays Left Rotation HackerRank Solution

  Рет қаралды 47,109

JAVAAID - Coding Interview Preparation

JAVAAID - Coding Interview Preparation

Күн бұрын

Пікірлер: 69
@JavaAidTutorials
@JavaAidTutorials 5 жыл бұрын
JAVAAID community: KZbin recently changed the way they monetize my content. My channel now needs 1,000 subscribers so it would be awesome if you could show your support by both watching my videos and subscribing to my channel. please hit the like button too, if you find it useful. if you haven’t already done so. Monetizing my videos allows me to invest back into the channel with new equipment so a small gesture from you goes a huge way for me. Many thanks for your support!
@sunilpatra9037
@sunilpatra9037 3 жыл бұрын
Wow, Amazed. That was quick. Thank you
@suchitragiri4546
@suchitragiri4546 4 жыл бұрын
yeah!! i got your point Thank you so muchh sir , i solved this problem using this logic but still i confused so , i decided to watching your video. Now i know the logic which is behind the code. 😊
@igorbarros9620
@igorbarros9620 4 жыл бұрын
I just wanna say thank you, man! I really appreciate your efforts creating this videos with explanations.
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
Glad you like them!
@srikarchatla5178
@srikarchatla5178 3 жыл бұрын
awesome bro you were just very clear about this i loved it
@mihirk953
@mihirk953 5 жыл бұрын
Excellent explanation. Very easy to understand. Thanks very much for providing this.
@JavaAidTutorials
@JavaAidTutorials 5 жыл бұрын
Most welcome..:)
@FirMizzZ
@FirMizzZ 3 жыл бұрын
thanks. your channel is the best explanation. keep doing.
@dilipshukla2135
@dilipshukla2135 5 жыл бұрын
Awesome observation and explanation!!!! I am happy to come acrossed this post on first day of the new year !!!! Thanks for sharing!!!
@JavaAidTutorials
@JavaAidTutorials 5 жыл бұрын
Thanks a lot for your lovely feedback. 😊 If you find our channel helpful, please do share among your friends.
@aakashmudigonda3375
@aakashmudigonda3375 4 жыл бұрын
You are an excellent teacher❤️
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
Thanks for the compliment 😊
@humzarahman1945
@humzarahman1945 3 жыл бұрын
Very helpful, thank you so much!
@perihanhill4397
@perihanhill4397 5 жыл бұрын
Thank you so much! I missed % in my program and was trying to understand what's going on. Please share more codes! :)
@JavaAidTutorials
@JavaAidTutorials 5 жыл бұрын
Most welcome 😊
@HugoAyala1983
@HugoAyala1983 4 жыл бұрын
Perfect solution and formula explanation such a clean solution
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
Glad you think so!
@vigneshhendrix4447
@vigneshhendrix4447 4 жыл бұрын
Just Vera Level Bro!✨🔥. Expecting more !✨
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
😊
@vrashankraom
@vrashankraom 3 жыл бұрын
By vector u can solve like this vector rotLeft(vector a, int d) { vectorarr; for(int j=d;j
@sushmitgoswami6836
@sushmitgoswami6836 3 жыл бұрын
is the same thing will work when rotation d is greater than array lenght?
@SoupTurtle16
@SoupTurtle16 5 жыл бұрын
Thanks for showing me an unique method of solving this
@JavaAidTutorials
@JavaAidTutorials 5 жыл бұрын
Most welcome..
@munazzainamulhaque8863
@munazzainamulhaque8863 4 жыл бұрын
Such a nice explanation ...Plz make more videos on Interview Preparation Kit
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
Thanks and sure. We already have a playlist which has couple of videos, you can go through that. kzbin.info/aero/PLSIpQf0NbcCleuffqepcYEU5HLoSY8B_X will add more videos to it future.
@officialnizam
@officialnizam 5 жыл бұрын
very good explanation
@JavaAidTutorials
@JavaAidTutorials 5 жыл бұрын
thanks, Nizam for your feedback. Keep watching, keep commenting. It really motivates me to do more and better for you all. please hit the like button too, if you find it useful.
@poomaniraj9375
@poomaniraj9375 5 жыл бұрын
Super Explanations
@JavaAidTutorials
@JavaAidTutorials 5 жыл бұрын
thank you..
@dibasbaral4740
@dibasbaral4740 5 жыл бұрын
Nice explanation keep it up
@JavaAidTutorials
@JavaAidTutorials 5 жыл бұрын
Thanks @Dibas
@org2989
@org2989 4 жыл бұрын
Where did you put the input? I did exactly the same as you did but I dont have the array's elements..
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
cross verify once, May be you have done some mistake code while implementing it
@ketanlalcheta4558
@ketanlalcheta4558 3 жыл бұрын
Can we avoid additional space of new array and sort in place from existing array ?
@kraisk
@kraisk 11 ай бұрын
That's quite easy if you use an additional array. Now, try to do this in place.
@arshneetkathuria4999
@arshneetkathuria4999 4 жыл бұрын
this logic is not working for rotation which are greater than length of array.....sir kindly tell any other optimal solution.
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
Can you provide your input and share your code? because this solution is tested and working fine.
@charanp9931
@charanp9931 5 жыл бұрын
Thumps up
@JavaAidTutorials
@JavaAidTutorials 5 жыл бұрын
Thanks..
@martinomamic
@martinomamic 3 жыл бұрын
Hi, first of all, thanks for your efforts, I haven't been doing these for a while now and getting back into it. What do you think about this solution? I've taken into account that array is smaller than "d". func rotLeft(a: [Int], d: Int) -> [Int] { var rearranged: [Int] = [] let arraySize = a.count let dividerIndex = arraySize > d ? d : d % arraySize rearranged = a.suffix(arraySize - dividerIndex) + a.prefix(dividerIndex) return rearranged }
@shaone_syem
@shaone_syem 4 жыл бұрын
One other solution that crossed my mind is using a linked list so that we add the first d elements at the end while also moving the head. Complexity O(d).
@DharmendraKumar-ut2bn
@DharmendraKumar-ut2bn 4 жыл бұрын
What if d=1, then RR will be more complex, right ?
@aishwaryaverma7129
@aishwaryaverma7129 5 жыл бұрын
if we had to do a right rotation then it would have been newindex=oldindex%n ?Is this correct?
@JavaAidTutorials
@JavaAidTutorials 5 жыл бұрын
what about d, you did not considered d at all in your formula then how you are going to find the new array without d ? just for analogy purpose- Suppose, people are standing in a queue as mention below (added their rank on top which can treat as index)- 1 2 3 4 5 6 7 💃💃💃💃 🚶💃💃 how far away the boy is? if look from left side, boy is on 5th place but if you look from the right side he is on 3rd place. and the same concept is used here to find left and right rotation...🙂
@vishalcoder4964
@vishalcoder4964 4 жыл бұрын
What is the exact space complexity of this code? I guess O(n), if so we can try Reversal Algorith that takes O(1) Space complexity... need not to mention, a very good approach followed here too!! hats ^
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
It is enough to say, time complexity is inversely propositional to space. So based on give constraint people can choose which approach they have to follow.
@AK_sheikh933
@AK_sheikh933 4 жыл бұрын
Sir I need help in one question in Dsad solving airport solution
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
you can ping me on Instagram, will review it, if possible will surely upload video on that.
@AK_sheikh933
@AK_sheikh933 4 жыл бұрын
@@JavaAidTutorials Thanks sir..I sent
@brandon-22
@brandon-22 5 жыл бұрын
now if i understood what you talk it would be perfect
@JavaAidTutorials
@JavaAidTutorials 5 жыл бұрын
Sorry, I did not get your comment. Did you understand this problem or not?
@anonymous8038-c4m
@anonymous8038-c4m 5 жыл бұрын
What about if we are trying to rotate n times?
@JavaAidTutorials
@JavaAidTutorials 5 жыл бұрын
Hi Rishabh, if you use the formula which is mentioned in the video you can see for rotating n times if you take modulo with n then result will be 0. it means no rotation at all. after n rotation array will become the same as it was in starting.
@jiteshkumar3112
@jiteshkumar3112 5 жыл бұрын
the array will remain same
@sanandapodder5027
@sanandapodder5027 5 жыл бұрын
i am getting output in array not in String though converted to String, help me sir
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
Did not get you. paste your code here with detailed explaination.
@damodaranm3044
@damodaranm3044 5 жыл бұрын
bro why dont u star a telegram or whatapp group . so the i we have any doubts u may sole it
@JavaAidTutorials
@JavaAidTutorials 5 жыл бұрын
We already have couple of telegram channels and groups, even whatsapp group as well, just check out the description of any video, you will come to know...😜
@AshuYadav-lk4rp
@AshuYadav-lk4rp 5 жыл бұрын
what is the complexity of this ? can it be better ?
@JavaAidTutorials
@JavaAidTutorials 5 жыл бұрын
both time & space complexity for this solution is O(n).
@indianking0017
@indianking0017 4 жыл бұрын
why this logic works only in java not in python or c++
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
The explained logic was generic, it should work in all language. would suggest try pasting your code here, will try to review it.
@indianking0017
@indianking0017 4 жыл бұрын
U r absolutly right i will revisit an check might be i was do8ng sm silly mistake..as i tried i c++ then in python then i have to do it in java there it worked.! Soo ill be seding the codes if still i can't debugg thanks javaaid page is soo helpful!!
@pradeepmondal4943
@pradeepmondal4943 4 жыл бұрын
Bro , we need 0(1) space solution
@kevinhu7581
@kevinhu7581 3 жыл бұрын
This is only work when d
@claire3946
@claire3946 4 жыл бұрын
I still don't get it. Why right rotation??
@JavaAidTutorials
@JavaAidTutorials 4 жыл бұрын
Let me explain in another way, if 10 people are standing in a row and someone ask who is standing at 6th position then there are two ways to find it, either from front (or left) will go to 6th place or from back(from right) we can go to 4th place. Hoping this analogy can help you to understand this better.
Sparse Arrays HackerRank Solution[Optimized Approach]
12:23
JAVAAID - Coding Interview Preparation
Рет қаралды 20 М.
Dependency Injection, The Best Pattern
13:16
CodeAesthetic
Рет қаралды 918 М.
Правильный подход к детям
00:18
Beatrise
Рет қаралды 11 МЛН
The Best Band 😅 #toshleh #viralshort
00:11
Toshleh
Рет қаралды 22 МЛН
人是不能做到吗?#火影忍者 #家人  #佐助
00:20
火影忍者一家
Рет қаралды 20 МЛН
Repeated String HackerRank Solution [Optimal Approach]
16:41
JAVAAID - Coding Interview Preparation
Рет қаралды 197 М.
Sliding Window Technique | Google Coding Interview | Maximum Size SubArray Of Size K
16:06
JAVAAID - Coding Interview Preparation
Рет қаралды 67 М.
these are the habits of the top 1% students, that you can do.
12:58
AI Is Making You An Illiterate Programmer
27:22
ThePrimeTime
Рет қаралды 302 М.
Java 2D arrays 🚚
8:06
Bro Code
Рет қаралды 201 М.
Кого Первым ИСКЛЮЧАТ из ШКОЛЫ !
25:03
Bigger Is Greater HackerRank Solution
11:50
JAVAAID - Coding Interview Preparation
Рет қаралды 16 М.
Backtracking (Think Like a Programmer)
13:02
V. Anton Spraul
Рет қаралды 353 М.
Count Triplets Hackerrank Solution | Interview Preparation Kit
29:59
JAVAAID - Coding Interview Preparation
Рет қаралды 37 М.
Master Pointers in C:  10X Your C Coding!
14:12
Dave's Garage
Рет қаралды 346 М.
Правильный подход к детям
00:18
Beatrise
Рет қаралды 11 МЛН