Slow C#


  • 0
    public class Solution {
        public string ReverseWords(string s) {
            s = s.Trim();
            string[] split = s.Split(' ');
            string result = "";
            for(int i = split.Length - 1;i>=0;i--)
            {
                if(split[i].Length > 0)
                {
                result+=split[i];
                result+=" ";
                }
            }
            result = result.Trim();
            return result;
            
        }
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.