C++ 12ms swap very simple


  • 0
    B

    class Solution {
    public:
    string reverseString(string s) {
    int length = s.length();
    for(int i = 0 ; i < length/2 ; i++)
    {
    swap(s[i],s[length-i-1]);
    }
    return s;
    }
    };


Log in to reply
 

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