LeetCode 151 : Reverse Words in a String | Strings | Striver SDE Sheet | C++

preview_player
Показать описание
🧸♥️ Catchup with us on Instagram ♥️🧸

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

Thanks for the video man, have been looking for someone for more than 6 hours to explain it from a beginner perspective :)

AbhishekKapoor
Автор

Absolutely mind-blowing to reverse the string without even going in reverse

karthikgururajan
Автор

Why this "i<n" condition is necessary to put in both the while loops when it is already specified in the outer while loop once?

kanikagola
Автор

Great approach!, quite simple with constant space and linear time complexity, I took inspiration from the rotate array and first reversed the whole string and then reverse individual word, but this is straight forward.

hemilfichadia
Автор

You have blown up my mind... very nicely explained

sajalaggarwal
Автор

great explanation!! keep making such solutions videos. They are very helpful

shreyarawatvlogs
Автор

only approach i was able to understand, but pls suggest how we can improve space complexity

Shakti_singh
Автор

that's the how a question explain in very simple way

arifalam
Автор

Thank you so much it was a crystal clear explanation.

aryansinha
Автор

What is time and space complexity?
TC-> O(s.size())
SC-> O(1) ?
Please correct me if i am wrong...

unnatimishra
Автор

great explanation!!, but in question it is mentioned that do not use extra space mean string.

pradeepdevilrathore
Автор

bro direct s[i] kaise kardiya ye java me nahi hoga na

nihal
Автор

hello bhaii isme reverse kaise hua yee samaj mein nhii aaya

my dry run prespective

int i=0;
int n = s.size();
string ans = ""; // we have create empty string

while( i < n) {
string temp=""; // also we create empty string

while(s[i[ != " " && i < n) {
temp + = s[i];
i++;
}
// iss loop se bhar aayenge too temp mein store hoga something like = The sky is blue

if(temp.size() > 0 ) {
if(ans.size() == 0) {

ans = temp; // yaha par ans mein store hoga temp ki value like = the sky is blue
}
else{
ans = temp + " " + ans;
}

}
return ans;

}

in this code where reverse part dont understand please explain me

AkashAde-hv
Автор

string reverse kese hui still cant understand 4 baar dekh li video

poetrystation
Автор

itni baar bola ki kaafi simple code hai ki khud itna bewakoof feel hua ki ab coding hi chodne ka mann hora h....nai ban raha tha tabhi toh aaya tha na bhai yaha...aise bolega toh kaise chalega..

chitranshverma
Автор

Can anybody explain this line of code?? temp += s[i];

ClashkingGaurav
Автор

time limit exceed kr gaya bhaiya leetcode pr

techcode
Автор

What will be the time complexity of this.
Ig O(n)

subratshukla