C# Solution


  • 0
    G
    public static string ReverseString(string s)
    {
    	if(s.Length == 1) return s;
    	int half = s.Length/2;
    	int j = s.Length -1;
    	var cs = s.ToCharArray();
    	for (int i = 0; i < half; i++)
    	{
    		char t = cs[i];
    		cs[i] = cs[j-i];
    		cs[j-i]= t;
    	}
    	return new string(cs);
    }
    

Log in to reply
 

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