Rotate Array | Rotation of Array in O(N) Time Complexity and O(1) space Complexity LeetCode Solution

preview_player
Показать описание
This is the video under the series of DATA STRUCTURE & ALGORITHM. We are going to solve Questions from Leetcode Rotation of Array in O(N) Time Complexity and O(1) space Complexity. This is a very famous and Routine question asked in the Interview. The question is from the Topics Data structure. A full easy concept in Hindi. This is Question is asked in Many companies like Google, Amazon, Oyo Rooms, Paytm, Samsung, Adobe, etc.
We also Provide courses on Competitive Programming and Data structure. Please see our Full Playlist on our Channel.
leetcode questions number 189
----------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------

*Follow me *

----------------------------------------------------------------------------------------

►Our Playlists on:-

------------------------------------------------------------------------

Our Students Contacts Form:-

------------------------------------------------------------------------

#interview_preparation #leeetcode #Hindi
Рекомендации по теме
Комментарии
Автор

What I love about your video is that you are not hiding your struggles and mistake. Today I learned what is problem solving in real life. Showing struggles and usuals mistakes should be part of teaching, You are awesome teacher. Thank you 😊.

iamrohit
Автор

Thank you soo much for including all your mistakes as well rather than posting the perfect solution. It makes bigger diffference than one might realise.

auraj
Автор

You are a champ. Yours simplicity will definitely take you to heights. Approach is very simple yet very efficient. Thank you ! You really earned a subscriber.

AshishMishra-ctiy
Автор

koi bhi question ka solution chahiye hota to sabse pahle aapka hi video dekhta hu agar video hota h usse related to. bahut accha explain karte ho aap

mukulbansal
Автор

this channel helps me not only in solving the problem but developing the logic and the concept behind the

pushpendrapundir
Автор

My approach:
For(int i=k;i<n;i++)
Cout<<arr[i];
For(int i=0;i<k;i++)
Cout<<arr[i];
That's it..

sahilpahuja
Автор

found your channel today, believe no one has ever motivated me the way you did . Definitely looking forward to learn DSA from your Question series . Thanks !

chickukoshti
Автор

Truth is the most beautiful thing in this world which god loves.... and u have that in your teaching

pkyadav
Автор

U can use just reverse function in stl for this problem
My approach was :
class Solution {
public:
void rotate(vector<int>& nums, int k) {

int n=nums.size();

k = k%n;

vector<int> v(n);
for(int i=0; i<n; i++){
v[(i+k)%n] = nums[i];
}

for(int i=0; i<n; i++){
nums[i] = v[i];
}

}
};

Here.s_how
Автор

No other YouTuber explains and extends the solution like you, you're very reliable

krishnarao
Автор

Best approach I have ever seen for rotating array. thank you so much

iamHasibulHasanJoy
Автор

Sir you know I am submit my very first codechef question by seeing your video
You are always my teacher

zafdell
Автор

bhai yaar aap bahot sahi kaam kar rahey ho bhaiya bahot accha padhate ho mera CP ka kabhi mann nahi hua lekin bhai tumhari video dekhne ke baad aise lagta hai i should start CP because you are creating such a good content for beginners

amankhairwar
Автор

Brilliant video brother... Thankyou so muchh❤

hemantvishwakarma
Автор

u deserve more appreciaton just make solving any problem very efficient.

priyasingh-lvii
Автор

Very nice explanation by video, you have done a lot of hardwork in making that slides and also it shows you are a very humble person. Keep growing!

vishalsrivastava
Автор

Great explanation. I had tried solving this by rotating elements k times(TLE). Then I solved using your method, by reversing the array to kth element, reversing from k+1 to end, and then reversing it entirely again. Thanks👌
*C++ code using STL 👇* :

class Solution {
public:
void rotate(vector<int>& nums, int k) {

int len = nums.size();
k = k%len;
reverse(nums.begin(), nums.begin() + len - k);

reverse(nums.begin() + len - k, nums.begin() + len);

reverse(nums.begin(), nums.begin() + len);
}
};

arjunprasad
Автор

Keep making more videos with such elaborate and concise explanation. Please make more videos on Leetcode/GFG interview questions frequently asked.

akhilmehta
Автор

literally bhaiya mza aa gya
pahli baar lga koi code rat kr nhi bta rha

jayantgupta
Автор

mast guru ji ho aap . bahut difficult cheeze bahut aasani se bata dete hai aap.

rahulgupta-qqdd