Horje
344. Reverse String c++ Code Example
reverse string c++
#include <iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
string str;
  getline(cin,str);
  reverse(str.begin(),str.end());
  cout<<str;
}
344. Reverse String c++
class Solution {
public:
    void reverseString(vector<char>& s) {
        int i=0;
        int j=s.size()-1;
        while(i<j)
        {
            swap(s[i],s[j]);
            i++;
            j--;
        }
    }
};

//Runtime: 20 ms, faster than 76.31% of C++ online submissions for Reverse String.
//Memory Usage: 23.3 MB, less than 38.31% of C++ online submissions for Reverse String.




Cpp

Related
how to delete a file in cpp Code Example how to delete a file in cpp Code Example
strring length in c++ Code Example strring length in c++ Code Example
how can we create 4 digit random number in c++ Code Example how can we create 4 digit random number in c++ Code Example
lambda function qt connect Code Example lambda function qt connect Code Example
prime factorisation of a number in c++ Code Example prime factorisation of a number in c++ Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
11