Solution by CreativeSelf


  • 0
    C
    class Solution {
    public:
        string reverseString(string s) {
            
            int low = 0; 
            int high = s.size() -1; 
            char temp; 
            
            while(high > low){
                temp = s[low]; 
                s[low] = s[high]; 
                s[high] = temp; 
                high--;
                low++;
            }       
            return s; 
        }
    };
    

Log in to reply
 

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