Day6. Namespace style

This commit is contained in:
Electrominch
2022-10-07 16:36:27 +03:00
parent 62104da8f1
commit 5cae083979
51 changed files with 589 additions and 202 deletions

View File

@@ -0,0 +1,25 @@
using System.Text;
namespace _557._Reverse_Words_in_a_String_III;
public class Solution
{
public string ReverseWords(string s)
{
StringBuilder sb = new StringBuilder();
for (int i = 0; i < s.Length; i++)
{
if (s[i] == ' ')
sb.Append(' ');
else
{
int startIndex = i;
while (i < s.Length - 1 && s[i + 1] != ' ')
i++;
for (int r = i; r >= startIndex; r--)
sb.Append(s[r]);
}
}
return sb.ToString();
}
}