C++ Solution for only two lines


  • 0
    L
    string reverseString(string s) {
         std::reverse(s.begin(), s.end());
         return s;
    

    }
    //12ms


  • 3
    A

    If your goal is just to have a short program...

    1 line:

    string reverseString(string s) {
         return std::reverse(s.begin(), s.end()),s;
    }
    

Log in to reply
 

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