Quick actions

cmd+k|ctrl+k

Navigation

Languages

Reverse a String Adv

Snippet info

Language

Cpp

Visibility

public

Author

amangoyal1727

Created

2021-01-06T21:48:35Z

Updated

2021-01-06T21:48:35Z

#include <iostream>
using namespace std;


int main() {
   cout<<"Enter a String: ";
   string S;
   getline(cin, S); //Way of taking String as a input with white Spaces
   char A[S.length()];
   for(int i=(S.length()-1) ; i>=0 ; i--){
       A[(S.length()-1)-i] = S[i];
   }
   for(int j=0 ; j<S.length();j++){
       cout<<A[j];
   }
}

//O(n) : Time Complexity
//O(n) : Space Complexity
INFO