557. Reverse Words in a String III Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order. Example 1: Input: "Let's take LeetCode contest" Output: "…
Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order. Example 1: Input: "Let's take LeetCode contest" Output: "s'teL ekat edoCteeL tsetnoc"…
public class Solution { public string ReverseWords(string s) { var list = s.Split(' ').AsEnumerable().ToList();//用空格将单词分隔开 ; i < list.Count(); i++)//循环每一个单词 { var str = list[i]; var chars = str.Reverse();//将这个单词反转 StringBuilder sb = new StringBuilder…