Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lect.22 Array String (Leetcode Question) #103

Closed
Justin-roy opened this issue Jan 3, 2022 · 1 comment
Closed

Lect.22 Array String (Leetcode Question) #103

Justin-roy opened this issue Jan 3, 2022 · 1 comment

Comments

@Justin-roy
Copy link

Video Timestamp - 55:15
Leetcode Question No- 151. Reverse Words in a String.

Bhaiya Ur Telling Reverse String But There Some Certain Condition have a look....

Here The My Solved Problem Code ..

class Solution {
public:
string reverseWords(string s) {
string ans;
stack stk;
int i = 0;
while(i < s.size()) {
string temp;
while(i < s.size() && s[i] == ' ') ++i;
while(i < s.size() && s[i] != ' ') {
temp.push_back(s[i++]);
}
if(temp.size() > 0)
stk.push(temp);
}
int j=0;
while(!stk.empty()) {
ans += stk.top(); stk.pop();
if(!stk.empty()) ans += ' ';
}
return ans;
}
};

@supersaint7780
Copy link
Contributor

For this purpose either create a new pull request or suggest an edit to original code. The create an issue feature is not for this purpose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants