Reverse Left Words

This commit is contained in:
2022-11-30 17:24:58 +08:00
parent 7b21a4bb3b
commit b13cfa00bb
5 changed files with 51 additions and 9 deletions

View File

@@ -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;