We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
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; } };
The text was updated successfully, but these errors were encountered:
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.
Sorry, something went wrong.
No branches or pull requests
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;
}
};
The text was updated successfully, but these errors were encountered: