Could I find the fastest C++ solution?


  • 1
    T

    class Solution {
    public:
    string reverseString(string s) {
    int i = 0;
    int j = s.size()-1;
    while (i < j){
    swap(s[i++],s[j--]);
    }
    return s;
    }
    };

    It takes 9ms
    But i want to know those 6ms solutions.
    someone can help me?


Log in to reply
 

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