Reverse Left Words
This commit is contained in:
@@ -1,14 +1,5 @@
|
||||
#include "s0151_reverse_words_in_a_string.hpp"
|
||||
|
||||
// reverse a substring
|
||||
void reverseSubStr(string &s, int begin, int end) {
|
||||
for (; begin < end; ++begin, --end) {
|
||||
auto tmp = s[begin];
|
||||
s[begin] = s[end];
|
||||
s[end] = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
string Solution::reverseWords(string s) {
|
||||
if (s.length() == 0) {
|
||||
return s;
|
||||
|
||||
Reference in New Issue
Block a user